Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions shell/platform/linux/testing/fl_test.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// FLUTTER_NOLINT

#include "gtest/gtest.h"

Expand All @@ -11,19 +10,21 @@
#include "flutter/shell/platform/linux/testing/mock_renderer.h"

static uint8_t hex_digit_to_int(char value) {
if (value >= '0' && value <= '9')
if (value >= '0' && value <= '9') {
return value - '0';
else if (value >= 'a' && value <= 'f')
} else if (value >= 'a' && value <= 'f') {
return value - 'a' + 10;
else if (value >= 'F' && value <= 'F')
} else if (value >= 'F' && value <= 'F') {
return value - 'A' + 10;
else
} else {
return 0;
}
}

static uint8_t parse_hex8(const gchar* hex_string) {
if (hex_string[0] == '\0')
if (hex_string[0] == '\0') {
return 0x00;
}
return hex_digit_to_int(hex_string[0]) << 4 | hex_digit_to_int(hex_string[1]);
}

Expand All @@ -41,8 +42,9 @@ gchar* bytes_to_hex_string(GBytes* bytes) {
size_t data_length;
const uint8_t* data =
static_cast<const uint8_t*>(g_bytes_get_data(bytes, &data_length));
for (size_t i = 0; i < data_length; i++)
for (size_t i = 0; i < data_length; i++) {
g_string_append_printf(hex_string, "%02x", data[i]);
}
return g_string_free(hex_string, FALSE);
}

Expand Down
38 changes: 25 additions & 13 deletions shell/platform/linux/testing/mock_egl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,14 @@ EGLBoolean eglChooseConfig(EGLDisplay dpy,
EGLConfig* configs,
EGLint config_size,
EGLint* num_config) {
if (!check_display(dpy) || !check_initialized(dpy))
if (!check_display(dpy) || !check_initialized(dpy)) {
return EGL_FALSE;
}

if (configs == nullptr) {
if (num_config != nullptr)
if (num_config != nullptr) {
*num_config = 1;
}
return bool_success();
}

Expand All @@ -112,8 +114,9 @@ EGLBoolean eglChooseConfig(EGLDisplay dpy,
n_returned++;
}

if (num_config != nullptr)
if (num_config != nullptr) {
*num_config = n_returned;
}

return bool_success();
}
Expand All @@ -122,8 +125,9 @@ EGLContext eglCreateContext(EGLDisplay dpy,
EGLConfig config,
EGLContext share_context,
const EGLint* attrib_list) {
if (!check_display(dpy) || !check_initialized(dpy) || !check_config(config))
if (!check_display(dpy) || !check_initialized(dpy) || !check_config(config)) {
return EGL_NO_CONTEXT;
}

mock_error = EGL_SUCCESS;
return &mock_context;
Expand All @@ -132,8 +136,9 @@ EGLContext eglCreateContext(EGLDisplay dpy,
EGLSurface eglCreatePbufferSurface(EGLDisplay dpy,
EGLConfig config,
const EGLint* attrib_list) {
if (!check_display(dpy) || !check_initialized(dpy) || !check_config(config))
if (!check_display(dpy) || !check_initialized(dpy) || !check_config(config)) {
return EGL_NO_SURFACE;
}

mock_error = EGL_SUCCESS;
return &mock_surface;
Expand All @@ -143,8 +148,9 @@ EGLSurface eglCreateWindowSurface(EGLDisplay dpy,
EGLConfig config,
EGLNativeWindowType win,
const EGLint* attrib_list) {
if (!check_display(dpy) || !check_initialized(dpy) || !check_config(config))
if (!check_display(dpy) || !check_initialized(dpy) || !check_config(config)) {
return EGL_NO_SURFACE;
}

mock_error = EGL_SUCCESS;
return &mock_surface;
Expand All @@ -154,8 +160,9 @@ EGLBoolean eglGetConfigAttrib(EGLDisplay dpy,
EGLConfig config,
EGLint attribute,
EGLint* value) {
if (!check_display(dpy) || !check_initialized(dpy) || !check_config(config))
if (!check_display(dpy) || !check_initialized(dpy) || !check_config(config)) {
return EGL_FALSE;
}

MockConfig* c = static_cast<MockConfig*>(config);
switch (attribute) {
Expand Down Expand Up @@ -261,8 +268,9 @@ void (*eglGetProcAddress(const char* procname))(void) {
}

EGLBoolean eglInitialize(EGLDisplay dpy, EGLint* major, EGLint* minor) {
if (!check_display(dpy))
if (!check_display(dpy)) {
return EGL_FALSE;
}

if (!display_initialized) {
mock_config.config_id = 1;
Expand Down Expand Up @@ -295,10 +303,12 @@ EGLBoolean eglInitialize(EGLDisplay dpy, EGLint* major, EGLint* minor) {
display_initialized = true;
}

if (major != nullptr)
if (major != nullptr) {
*major = 1;
if (minor != nullptr)
*major = 5;
}
if (minor != nullptr) {
*minor = 5;
}

return bool_success();
}
Expand All @@ -307,15 +317,17 @@ EGLBoolean eglMakeCurrent(EGLDisplay dpy,
EGLSurface draw,
EGLSurface read,
EGLContext ctx) {
if (!check_display(dpy) || !check_initialized(dpy))
if (!check_display(dpy) || !check_initialized(dpy)) {
return EGL_FALSE;
}

return bool_success();
}

EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) {
if (!check_display(dpy) || !check_initialized(dpy))
if (!check_display(dpy) || !check_initialized(dpy)) {
return EGL_FALSE;
}

return bool_success();
}