| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/sessions/restore_on_startup_policy_handler.h" | 5 #include "chrome/browser/sessions/restore_on_startup_policy_handler.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 SetPolicyValue(key::kRestoreOnStartup, | 123 SetPolicyValue(key::kRestoreOnStartup, |
| 124 base::MakeUnique<base::Value>(not_home_page)); | 124 base::MakeUnique<base::Value>(not_home_page)); |
| 125 ApplyPolicySettings(); | 125 ApplyPolicySettings(); |
| 126 // The resulting prefs should have the value we specified. | 126 // The resulting prefs should have the value we specified. |
| 127 int result; | 127 int result; |
| 128 EXPECT_TRUE(prefs().GetInteger(prefs::kRestoreOnStartup, &result)); | 128 EXPECT_TRUE(prefs().GetInteger(prefs::kRestoreOnStartup, &result)); |
| 129 EXPECT_EQ(not_home_page, result); | 129 EXPECT_EQ(not_home_page, result); |
| 130 } | 130 } |
| 131 | 131 |
| 132 TEST_F(RestoreOnStartupPolicyHandlerTest, | 132 TEST_F(RestoreOnStartupPolicyHandlerTest, |
| 133 CheckPolicySettings_RestoreLastSession_ClearDataOnExit) { | |
| 134 // Specify the Last value and the Clear-Data-On-Exit value. | |
| 135 SetPolicyValue( | |
| 136 key::kRestoreOnStartup, | |
| 137 base::WrapUnique(new base::Value(SessionStartupPref::kPrefValueLast))); | |
| 138 SetPolicyValue(key::kClearSiteDataOnExit, | |
| 139 base::MakeUnique<base::Value>(true)); | |
| 140 // Checking should succeed but add an error to the error map. | |
| 141 EXPECT_TRUE(CheckPolicySettings()); | |
| 142 ASSERT_EQ(1U, errors().size()); | |
| 143 EXPECT_EQ(key::kClearSiteDataOnExit, errors().begin()->first); | |
| 144 EXPECT_EQ(l10n_util::GetStringFUTF16( | |
| 145 IDS_POLICY_OVERRIDDEN, | |
| 146 base::ASCIIToUTF16(key::kRestoreOnStartup)), | |
| 147 errors().begin()->second); | |
| 148 } | |
| 149 | |
| 150 TEST_F(RestoreOnStartupPolicyHandlerTest, | |
| 151 CheckPolicySettings_RestoreLastSession) { | 133 CheckPolicySettings_RestoreLastSession) { |
| 152 // Specify the Last value without the conflicts. | 134 // Specify the Last value without the conflicts. |
| 153 SetPolicyValue( | 135 SetPolicyValue( |
| 154 key::kRestoreOnStartup, | 136 key::kRestoreOnStartup, |
| 155 base::WrapUnique(new base::Value(SessionStartupPref::kPrefValueLast))); | 137 base::WrapUnique(new base::Value(SessionStartupPref::kPrefValueLast))); |
| 156 // Checking should succeed with no errors. | 138 // Checking should succeed with no errors. |
| 157 EXPECT_TRUE(CheckPolicySettings()); | 139 EXPECT_TRUE(CheckPolicySettings()); |
| 158 EXPECT_TRUE(errors().empty()); | 140 EXPECT_TRUE(errors().empty()); |
| 159 } | 141 } |
| 160 | 142 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 186 } | 168 } |
| 187 | 169 |
| 188 TEST_F(RestoreOnStartupPolicyHandlerTest, ApplyPolicySettings_WrongType) { | 170 TEST_F(RestoreOnStartupPolicyHandlerTest, ApplyPolicySettings_WrongType) { |
| 189 // Handler expects an int; pass it a bool. | 171 // Handler expects an int; pass it a bool. |
| 190 SetPolicyValue(key::kRestoreOnStartup, base::MakeUnique<base::Value>(false)); | 172 SetPolicyValue(key::kRestoreOnStartup, base::MakeUnique<base::Value>(false)); |
| 191 // The resulting prefs should be empty. | 173 // The resulting prefs should be empty. |
| 192 EXPECT_TRUE(prefs().empty()); | 174 EXPECT_TRUE(prefs().empty()); |
| 193 } | 175 } |
| 194 | 176 |
| 195 } // namespace policy | 177 } // namespace policy |
| OLD | NEW |