From 6ef17f9ebdc9ce83a53b2c652f6ed379ff150475 Mon Sep 17 00:00:00 2001 From: Simon Hong Date: Wed, 25 Aug 2021 18:19:47 +0900 Subject: [PATCH 1/2] Fixed first-run dialog is not launched fix https://github.com/brave/brave-browser/issues/17667 With https://bugs.chromium.org/p/chromium/issues/detail?id=1243221, Local State file is created at the startup. When, "Local State" file is already existed ShouldShowFirstRunDialog(). Due to this, dialog is launched ramdomly only when this file is not stored in FS becfore calling ShouldShowFirstRunDialog(). Browser only tries to run this dialog when first_run::IsChromeFirstRun() is true. Checking "Local State" file again is redundant. Removed this checking. --- .../first_run/first_run_internal_posix.cc | 2 ++ common/BUILD.gn | 12 ++++++++++++ common/brave_paths_unittest.cc | 16 ++++++++++++++++ test/BUILD.gn | 1 + 4 files changed, 31 insertions(+) create mode 100644 common/brave_paths_unittest.cc diff --git a/chromium_src/chrome/browser/first_run/first_run_internal_posix.cc b/chromium_src/chrome/browser/first_run/first_run_internal_posix.cc index 27be1abcf61b..e4caa4fe07e8 100644 --- a/chromium_src/chrome/browser/first_run/first_run_internal_posix.cc +++ b/chromium_src/chrome/browser/first_run/first_run_internal_posix.cc @@ -32,8 +32,10 @@ #if defined(OFFICIAL_BUILD) #undef BUILDFLAG_INTERNAL_GOOGLE_CHROME_BRANDING #define BUILDFLAG_INTERNAL_GOOGLE_CHROME_BRANDING() (1) +#define FILE_LOCAL_STATE PATH_END #endif #include "../../../../../chrome/browser/first_run/first_run_internal_posix.cc" #if defined(OFFICIAL_BUILD) #undef BUILDFLAG_INTERNAL_GOOGLE_CHROME_BRANDING +#undef FILE_LOCAL_STATE #endif diff --git a/common/BUILD.gn b/common/BUILD.gn index 1458f9dd312a..4ea2ccab90fe 100644 --- a/common/BUILD.gn +++ b/common/BUILD.gn @@ -185,6 +185,18 @@ config("constants_configs") { } } +source_set("unit_tests") { + testonly = true + sources = [ "brave_paths_unittest.cc" ] + + deps = [ + "//base", + "//brave/common", + "//chrome/common", + "//testing/gtest", + ] +} + mojom("mojo_bindings") { sources = [ "brave_renderer_configuration.mojom" ] diff --git a/common/brave_paths_unittest.cc b/common/brave_paths_unittest.cc new file mode 100644 index 000000000000..af3a43b2bd77 --- /dev/null +++ b/common/brave_paths_unittest.cc @@ -0,0 +1,16 @@ +/* Copyright (c) 2021 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "brave/common/brave_paths.h" +#include "base/files/file_path.h" +#include "base/path_service.h" +#include "chrome/common/chrome_paths.h" +#include "testing/gtest/include/gtest/gtest.h" + +TEST(BravePathsTest, PathTest) { + base::FilePath test_dir; + EXPECT_TRUE(base::PathService::Get(brave::DIR_TEST_DATA, &test_dir)); + EXPECT_FALSE(base::PathService::Get(chrome::PATH_END, &test_dir)); +} diff --git a/test/BUILD.gn b/test/BUILD.gn index 969a6a9684f6..c830cbf0de4d 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -175,6 +175,7 @@ test("brave_unit_tests") { "//brave/chromium_src/components/autofill_assistant/browser:unit_tests", "//brave/common:network_constants", "//brave/common:pref_names", + "//brave/common:unit_tests", "//brave/components/adblock_rust_ffi", "//brave/components/brave_ads/test:brave_ads_unit_tests", "//brave/components/brave_component_updater/browser", From 7077d020f52eff6ca532a3753b0f03aa1014500b Mon Sep 17 00:00:00 2001 From: Simon Hong Date: Wed, 25 Aug 2021 20:32:40 +0900 Subject: [PATCH 2/2] Fixed ios CI failure --- common/BUILD.gn | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/common/BUILD.gn b/common/BUILD.gn index 4ea2ccab90fe..96ad4575d3a4 100644 --- a/common/BUILD.gn +++ b/common/BUILD.gn @@ -187,14 +187,17 @@ config("constants_configs") { source_set("unit_tests") { testonly = true - sources = [ "brave_paths_unittest.cc" ] - deps = [ - "//base", - "//brave/common", - "//chrome/common", - "//testing/gtest", - ] + if (!is_ios) { + sources = [ "brave_paths_unittest.cc" ] + + deps = [ + "//base", + "//brave/common", + "//chrome/common", + "//testing/gtest", + ] + } } mojom("mojo_bindings") {