Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: chrome/browser/policy/policy_browsertest.cc

Issue 1312693005: Remove migration of obsolete value for "session.restore_on_startup". (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@url-to-restore-on-startup
Patch Set: Address comments by bartfab & rebase Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <algorithm> 5 #include <algorithm>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 3177 matching lines...) Expand 10 before | Expand all | Expand 10 after
3188 } 3188 }
3189 3189
3190 void SetUpOnMainThread() override { 3190 void SetUpOnMainThread() override {
3191 BrowserThread::PostTask( 3191 BrowserThread::PostTask(
3192 BrowserThread::IO, 3192 BrowserThread::IO,
3193 FROM_HERE, 3193 FROM_HERE,
3194 base::Bind( 3194 base::Bind(
3195 RedirectHostsToTestData, kRestoredURLs, arraysize(kRestoredURLs))); 3195 RedirectHostsToTestData, kRestoredURLs, arraysize(kRestoredURLs)));
3196 } 3196 }
3197 3197
3198 void HomepageIsNotNTP() {
3199 // Verifies that policy can set the startup pages to the homepage, when
3200 // the homepage is not the NTP.
3201 PolicyMap policies;
3202 policies.Set(
3203 key::kRestoreOnStartup,
3204 POLICY_LEVEL_MANDATORY,
3205 POLICY_SCOPE_USER,
3206 new base::FundamentalValue(SessionStartupPref::kPrefValueHomePage),
3207 NULL);
3208 policies.Set(key::kHomepageIsNewTabPage,
3209 POLICY_LEVEL_MANDATORY,
3210 POLICY_SCOPE_USER,
3211 new base::FundamentalValue(false),
3212 NULL);
3213 policies.Set(key::kHomepageLocation,
3214 POLICY_LEVEL_MANDATORY,
3215 POLICY_SCOPE_USER,
3216 new base::StringValue(kRestoredURLs[1]),
3217 NULL);
3218 provider_.UpdateChromePolicy(policies);
3219
3220 expected_urls_.push_back(GURL(kRestoredURLs[1]));
3221 }
3222
3223 void HomepageIsNTP() {
3224 // Verifies that policy can set the startup pages to the homepage, when
3225 // the homepage is the NTP.
3226 PolicyMap policies;
3227 policies.Set(
3228 key::kRestoreOnStartup,
3229 POLICY_LEVEL_MANDATORY,
3230 POLICY_SCOPE_USER,
3231 new base::FundamentalValue(SessionStartupPref::kPrefValueHomePage),
3232 NULL);
3233 policies.Set(key::kHomepageIsNewTabPage,
3234 POLICY_LEVEL_MANDATORY,
3235 POLICY_SCOPE_USER,
3236 new base::FundamentalValue(true),
3237 NULL);
3238 provider_.UpdateChromePolicy(policies);
3239
3240 expected_urls_.push_back(GURL(chrome::kChromeUINewTabURL));
3241 }
3242
3243 void ListOfURLs() { 3198 void ListOfURLs() {
3244 // Verifies that policy can set the startup pages to a list of URLs. 3199 // Verifies that policy can set the startup pages to a list of URLs.
3245 base::ListValue urls; 3200 base::ListValue urls;
3246 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) { 3201 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) {
3247 urls.Append(new base::StringValue(kRestoredURLs[i])); 3202 urls.Append(new base::StringValue(kRestoredURLs[i]));
3248 expected_urls_.push_back(GURL(kRestoredURLs[i])); 3203 expected_urls_.push_back(GURL(kRestoredURLs[i]));
3249 } 3204 }
3250 PolicyMap policies; 3205 PolicyMap policies;
3251 policies.Set(key::kRestoreOnStartup, 3206 policies.Set(key::kRestoreOnStartup,
3252 POLICY_LEVEL_MANDATORY, 3207 POLICY_LEVEL_MANDATORY,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
3316 int size = static_cast<int>(expected_urls_.size()); 3271 int size = static_cast<int>(expected_urls_.size());
3317 EXPECT_EQ(size, model->count()); 3272 EXPECT_EQ(size, model->count());
3318 for (int i = 0; i < size && i < model->count(); ++i) { 3273 for (int i = 0; i < size && i < model->count(); ++i) {
3319 EXPECT_EQ(expected_urls_[i], model->GetWebContentsAt(i)->GetURL()); 3274 EXPECT_EQ(expected_urls_[i], model->GetWebContentsAt(i)->GetURL());
3320 } 3275 }
3321 } 3276 }
3322 3277
3323 INSTANTIATE_TEST_CASE_P( 3278 INSTANTIATE_TEST_CASE_P(
3324 RestoreOnStartupPolicyTestInstance, 3279 RestoreOnStartupPolicyTestInstance,
3325 RestoreOnStartupPolicyTest, 3280 RestoreOnStartupPolicyTest,
3326 testing::Values(&RestoreOnStartupPolicyTest::HomepageIsNotNTP, 3281 testing::Values(&RestoreOnStartupPolicyTest::ListOfURLs,
3327 &RestoreOnStartupPolicyTest::HomepageIsNTP,
3328 &RestoreOnStartupPolicyTest::ListOfURLs,
3329 &RestoreOnStartupPolicyTest::NTP, 3282 &RestoreOnStartupPolicyTest::NTP,
3330 &RestoreOnStartupPolicyTest::Last)); 3283 &RestoreOnStartupPolicyTest::Last));
3331 3284
3332 // Similar to PolicyTest but sets a couple of policies before the browser is 3285 // Similar to PolicyTest but sets a couple of policies before the browser is
3333 // started. 3286 // started.
3334 class PolicyStatisticsCollectorTest : public PolicyTest { 3287 class PolicyStatisticsCollectorTest : public PolicyTest {
3335 public: 3288 public:
3336 PolicyStatisticsCollectorTest() {} 3289 PolicyStatisticsCollectorTest() {}
3337 ~PolicyStatisticsCollectorTest() override {} 3290 ~PolicyStatisticsCollectorTest() override {}
3338 3291
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
3864 3817
3865 IN_PROC_BROWSER_TEST_F(HardwareAccelerationModePolicyTest, 3818 IN_PROC_BROWSER_TEST_F(HardwareAccelerationModePolicyTest,
3866 HardwareAccelerationDisabled) { 3819 HardwareAccelerationDisabled) {
3867 // Verifies that hardware acceleration can be disabled with policy. 3820 // Verifies that hardware acceleration can be disabled with policy.
3868 EXPECT_FALSE( 3821 EXPECT_FALSE(
3869 content::GpuDataManager::GetInstance()->GpuAccessAllowed(nullptr)); 3822 content::GpuDataManager::GetInstance()->GpuAccessAllowed(nullptr));
3870 } 3823 }
3871 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) 3824 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
3872 3825
3873 } // namespace policy 3826 } // namespace policy
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/prefs/session_startup_pref.h » ('j') | chrome/browser/prefs/session_startup_pref.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698