#include <memory>
#include <string>
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/memory/ref_counted.h"
#include "base/numerics/safe_conversions.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/threading/thread_restrictions.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/component_loader.h"
#include "chrome/browser/first_run/first_run.h"
#include "chrome/browser/first_run/first_run_internal.h"
#include "chrome/browser/importer/importer_list.h"
#include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
#include "chrome/browser/prefs/chrome_pref_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/prefs/pref_service.h"
#include "components/user_prefs/user_prefs.h"
#include "components/variations/metrics.h"
#include "components/variations/pref_names.h"
#include "components/variations/variations_switches.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_launcher.h"
#include "testing/gtest/include/gtest/gtest.h"
FirstRunBrowserTest;
namespace first_run {
#if !BUILDFLAG(IS_CHROMEOS)
namespace {
class FirstRunMasterPrefsBrowserTestBase : public InProcessBrowserTest { … };
template<const char Text[]>
class FirstRunMasterPrefsBrowserTestT
: public FirstRunMasterPrefsBrowserTestBase { … };
int MaskExpectedImportState(int expected_import_state) { … }
}
const char kImportDefault[] = …;
FirstRunMasterPrefsImportDefault;
IN_PROC_BROWSER_TEST_F(FirstRunMasterPrefsImportDefault, ImportDefault) { … }
const char kImportAll[] = …;
FirstRunMasterPrefsImportAll;
IN_PROC_BROWSER_TEST_F(FirstRunMasterPrefsImportAll, ImportAll) { … }
const char kImportBookmarksFile[] = …;
FirstRunMasterPrefsImportBookmarksFile;
IN_PROC_BROWSER_TEST_F(FirstRunMasterPrefsImportBookmarksFile,
ImportBookmarksFile) { … }
const char kImportNothing[] = …;
FirstRunMasterPrefsImportNothing;
IN_PROC_BROWSER_TEST_F(FirstRunMasterPrefsImportNothing,
ImportNothingAndShowNewTabPage) { … }
const char kWithTrackedPrefs[] = …;
class FirstRunMasterPrefsWithTrackedPreferences
: public FirstRunMasterPrefsBrowserTestT<kWithTrackedPrefs> { … };
IN_PROC_BROWSER_TEST_F(FirstRunMasterPrefsWithTrackedPreferences,
TrackedPreferencesSurviveFirstRun) { … }
#define COMPRESSED_SEED_TEST_VALUE …
#define SEED_SIGNATURE_TEST_VALUE …
constexpr char kCompressedSeedTestValue[] = …;
constexpr char kSignatureValue[] = …;
const char kWithVariationsPrefs[] = …;
#undef COMPRESSED_SEED_TEST_VALUE
#undef SEED_SIGNATURE_TEST_VALUE
class FirstRunMasterPrefsVariationsSeedTest
: public FirstRunMasterPrefsBrowserTestT<kWithVariationsPrefs>,
public testing::WithParamInterface<bool> { … };
IN_PROC_BROWSER_TEST_P(FirstRunMasterPrefsVariationsSeedTest, Test) { … }
#if BUILDFLAG(IS_WIN)
constexpr char kTrialName[] = "UMA-Uniformity-Trial-10-Percent";
const char* kTrialGroups[] = {"default", "group_01", "group_02", "group_03",
"group_04", "group_05", "group_06", "group_07",
"group_08", "group_09"};
IN_PROC_BROWSER_TEST_P(FirstRunMasterPrefsVariationsSeedTest, PRE_SecondRun) {
const std::string group_name = base::FieldTrialList::FindFullName(kTrialName);
ASSERT_TRUE(base::Contains(kTrialGroups, group_name)) << group_name;
ASSERT_TRUE(base::FieldTrialList::IsTrialActive(kTrialName));
WriteTrialGroupToTestFile(group_name);
}
IN_PROC_BROWSER_TEST_P(FirstRunMasterPrefsVariationsSeedTest, SecondRun) {
const std::string group_name = base::FieldTrialList::FindFullName(kTrialName);
ASSERT_TRUE(base::Contains(kTrialGroups, group_name)) << group_name;
ASSERT_TRUE(base::FieldTrialList::IsTrialActive(kTrialName));
EXPECT_EQ(group_name, ReadTrialGroupFromTestFile());
}
#endif
INSTANTIATE_TEST_SUITE_P(…);
#endif
}