| OLD | NEW |
| 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 "ash/display/display_manager.h" | 9 #include "ash/display/display_manager.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 3250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3261 } | 3261 } |
| 3262 | 3262 |
| 3263 void SetUpOnMainThread() override { | 3263 void SetUpOnMainThread() override { |
| 3264 BrowserThread::PostTask( | 3264 BrowserThread::PostTask( |
| 3265 BrowserThread::IO, | 3265 BrowserThread::IO, |
| 3266 FROM_HERE, | 3266 FROM_HERE, |
| 3267 base::Bind( | 3267 base::Bind( |
| 3268 RedirectHostsToTestData, kRestoredURLs, arraysize(kRestoredURLs))); | 3268 RedirectHostsToTestData, kRestoredURLs, arraysize(kRestoredURLs))); |
| 3269 } | 3269 } |
| 3270 | 3270 |
| 3271 void HomepageIsNotNTP() { | |
| 3272 // Verifies that policy can set the startup pages to the homepage, when | |
| 3273 // the homepage is not the NTP. | |
| 3274 PolicyMap policies; | |
| 3275 policies.Set( | |
| 3276 key::kRestoreOnStartup, | |
| 3277 POLICY_LEVEL_MANDATORY, | |
| 3278 POLICY_SCOPE_USER, | |
| 3279 POLICY_SOURCE_CLOUD, | |
| 3280 new base::FundamentalValue(SessionStartupPref::kPrefValueHomePage), | |
| 3281 NULL); | |
| 3282 policies.Set(key::kHomepageIsNewTabPage, | |
| 3283 POLICY_LEVEL_MANDATORY, | |
| 3284 POLICY_SCOPE_USER, | |
| 3285 POLICY_SOURCE_CLOUD, | |
| 3286 new base::FundamentalValue(false), | |
| 3287 NULL); | |
| 3288 policies.Set(key::kHomepageLocation, | |
| 3289 POLICY_LEVEL_MANDATORY, | |
| 3290 POLICY_SCOPE_USER, | |
| 3291 POLICY_SOURCE_CLOUD, | |
| 3292 new base::StringValue(kRestoredURLs[1]), | |
| 3293 NULL); | |
| 3294 provider_.UpdateChromePolicy(policies); | |
| 3295 | |
| 3296 expected_urls_.push_back(GURL(kRestoredURLs[1])); | |
| 3297 } | |
| 3298 | |
| 3299 void HomepageIsNTP() { | |
| 3300 // Verifies that policy can set the startup pages to the homepage, when | |
| 3301 // the homepage is the NTP. | |
| 3302 PolicyMap policies; | |
| 3303 policies.Set( | |
| 3304 key::kRestoreOnStartup, | |
| 3305 POLICY_LEVEL_MANDATORY, | |
| 3306 POLICY_SCOPE_USER, | |
| 3307 POLICY_SOURCE_CLOUD, | |
| 3308 new base::FundamentalValue(SessionStartupPref::kPrefValueHomePage), | |
| 3309 NULL); | |
| 3310 policies.Set(key::kHomepageIsNewTabPage, | |
| 3311 POLICY_LEVEL_MANDATORY, | |
| 3312 POLICY_SCOPE_USER, | |
| 3313 POLICY_SOURCE_CLOUD, | |
| 3314 new base::FundamentalValue(true), | |
| 3315 NULL); | |
| 3316 provider_.UpdateChromePolicy(policies); | |
| 3317 | |
| 3318 expected_urls_.push_back(GURL(chrome::kChromeUINewTabURL)); | |
| 3319 } | |
| 3320 | |
| 3321 void ListOfURLs() { | 3271 void ListOfURLs() { |
| 3322 // Verifies that policy can set the startup pages to a list of URLs. | 3272 // Verifies that policy can set the startup pages to a list of URLs. |
| 3323 base::ListValue urls; | 3273 base::ListValue urls; |
| 3324 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) { | 3274 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) { |
| 3325 urls.Append(new base::StringValue(kRestoredURLs[i])); | 3275 urls.Append(new base::StringValue(kRestoredURLs[i])); |
| 3326 expected_urls_.push_back(GURL(kRestoredURLs[i])); | 3276 expected_urls_.push_back(GURL(kRestoredURLs[i])); |
| 3327 } | 3277 } |
| 3328 PolicyMap policies; | 3278 PolicyMap policies; |
| 3329 policies.Set(key::kRestoreOnStartup, | 3279 policies.Set(key::kRestoreOnStartup, |
| 3330 POLICY_LEVEL_MANDATORY, | 3280 POLICY_LEVEL_MANDATORY, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3397 int size = static_cast<int>(expected_urls_.size()); | 3347 int size = static_cast<int>(expected_urls_.size()); |
| 3398 EXPECT_EQ(size, model->count()); | 3348 EXPECT_EQ(size, model->count()); |
| 3399 for (int i = 0; i < size && i < model->count(); ++i) { | 3349 for (int i = 0; i < size && i < model->count(); ++i) { |
| 3400 EXPECT_EQ(expected_urls_[i], model->GetWebContentsAt(i)->GetURL()); | 3350 EXPECT_EQ(expected_urls_[i], model->GetWebContentsAt(i)->GetURL()); |
| 3401 } | 3351 } |
| 3402 } | 3352 } |
| 3403 | 3353 |
| 3404 INSTANTIATE_TEST_CASE_P( | 3354 INSTANTIATE_TEST_CASE_P( |
| 3405 RestoreOnStartupPolicyTestInstance, | 3355 RestoreOnStartupPolicyTestInstance, |
| 3406 RestoreOnStartupPolicyTest, | 3356 RestoreOnStartupPolicyTest, |
| 3407 testing::Values(&RestoreOnStartupPolicyTest::HomepageIsNotNTP, | 3357 testing::Values(&RestoreOnStartupPolicyTest::ListOfURLs, |
| 3408 &RestoreOnStartupPolicyTest::HomepageIsNTP, | |
| 3409 &RestoreOnStartupPolicyTest::ListOfURLs, | |
| 3410 &RestoreOnStartupPolicyTest::NTP, | 3358 &RestoreOnStartupPolicyTest::NTP, |
| 3411 &RestoreOnStartupPolicyTest::Last)); | 3359 &RestoreOnStartupPolicyTest::Last)); |
| 3412 | 3360 |
| 3413 // Similar to PolicyTest but sets a couple of policies before the browser is | 3361 // Similar to PolicyTest but sets a couple of policies before the browser is |
| 3414 // started. | 3362 // started. |
| 3415 class PolicyStatisticsCollectorTest : public PolicyTest { | 3363 class PolicyStatisticsCollectorTest : public PolicyTest { |
| 3416 public: | 3364 public: |
| 3417 PolicyStatisticsCollectorTest() {} | 3365 PolicyStatisticsCollectorTest() {} |
| 3418 ~PolicyStatisticsCollectorTest() override {} | 3366 ~PolicyStatisticsCollectorTest() override {} |
| 3419 | 3367 |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3985 POLICY_SCOPE_USER, | 3933 POLICY_SCOPE_USER, |
| 3986 POLICY_SOURCE_CLOUD, | 3934 POLICY_SOURCE_CLOUD, |
| 3987 new base::FundamentalValue(false), | 3935 new base::FundamentalValue(false), |
| 3988 NULL); | 3936 NULL); |
| 3989 UpdateProviderPolicy(policies); | 3937 UpdateProviderPolicy(policies); |
| 3990 EXPECT_FALSE(display_manager->unified_desktop_enabled()); | 3938 EXPECT_FALSE(display_manager->unified_desktop_enabled()); |
| 3991 } | 3939 } |
| 3992 #endif // defined(OS_CHROMEOS) | 3940 #endif // defined(OS_CHROMEOS) |
| 3993 | 3941 |
| 3994 } // namespace policy | 3942 } // namespace policy |
| OLD | NEW |