OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/test/scoped_path_override.h" | 8 #include "base/test/scoped_path_override.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/first_run/first_run.h" | 10 #include "chrome/browser/first_run/first_run.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 79 |
80 TEST_F(FirstRunTest, | 80 TEST_F(FirstRunTest, |
81 SetupMasterPrefsFromInstallPrefs_WelcomePageOnOSUpgradeDisabled) { | 81 SetupMasterPrefsFromInstallPrefs_WelcomePageOnOSUpgradeDisabled) { |
82 installer::MasterPreferences install_prefs( | 82 installer::MasterPreferences install_prefs( |
83 "{\"distribution\":{\"welcome_page_on_os_upgrade_enabled\": false}}"); | 83 "{\"distribution\":{\"welcome_page_on_os_upgrade_enabled\": false}}"); |
84 MasterPrefs out_prefs; | 84 MasterPrefs out_prefs; |
85 internal::SetupMasterPrefsFromInstallPrefs(install_prefs, &out_prefs); | 85 internal::SetupMasterPrefsFromInstallPrefs(install_prefs, &out_prefs); |
86 EXPECT_FALSE(out_prefs.welcome_page_on_os_upgrade_enabled); | 86 EXPECT_FALSE(out_prefs.welcome_page_on_os_upgrade_enabled); |
87 } | 87 } |
88 | 88 |
| 89 // No switches and no sentinel present. This is the standard case for first run. |
| 90 TEST_F(FirstRunTest, DetermineFirstRunState_FirstRun) { |
| 91 internal::FirstRunState result = |
| 92 internal::DetermineFirstRunState(false, false, false); |
| 93 EXPECT_EQ(internal::FIRST_RUN_TRUE, result); |
| 94 } |
| 95 |
| 96 // Force switch is present, overriding both sentinel and suppress switch. |
| 97 TEST_F(FirstRunTest, DetermineFirstRunState_ForceSwitch) { |
| 98 internal::FirstRunState result = |
| 99 internal::DetermineFirstRunState(true, true, true); |
| 100 EXPECT_EQ(internal::FIRST_RUN_TRUE, result); |
| 101 |
| 102 result = internal::DetermineFirstRunState(true, true, false); |
| 103 EXPECT_EQ(internal::FIRST_RUN_TRUE, result); |
| 104 |
| 105 result = internal::DetermineFirstRunState(false, true, true); |
| 106 EXPECT_EQ(internal::FIRST_RUN_TRUE, result); |
| 107 |
| 108 result = internal::DetermineFirstRunState(false, true, false); |
| 109 EXPECT_EQ(internal::FIRST_RUN_TRUE, result); |
| 110 } |
| 111 |
| 112 // No switches, but sentinel present. This is not a first run. |
| 113 TEST_F(FirstRunTest, DetermineFirstRunState_NotFirstRun) { |
| 114 internal::FirstRunState result = |
| 115 internal::DetermineFirstRunState(true, false, false); |
| 116 EXPECT_EQ(internal::FIRST_RUN_FALSE, result); |
| 117 } |
| 118 |
| 119 // Suppress switch is present, overriding sentinel state. |
| 120 TEST_F(FirstRunTest, DetermineFirstRunState_SuppressSwitch) { |
| 121 internal::FirstRunState result = |
| 122 internal::DetermineFirstRunState(false, false, true); |
| 123 EXPECT_EQ(internal::FIRST_RUN_FALSE, result); |
| 124 |
| 125 result = internal::DetermineFirstRunState(true, false, true); |
| 126 EXPECT_EQ(internal::FIRST_RUN_FALSE, result); |
| 127 } |
| 128 |
89 } // namespace first_run | 129 } // namespace first_run |
OLD | NEW |