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