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

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

Issue 385263004: Get rid of some uses of CreateIntegerValue (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 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 | Annotate | Revision Log
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 836 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 EXPECT_TRUE(content::SetCookie(profile, url, value)); 847 EXPECT_TRUE(content::SetCookie(profile, url, value));
848 // Verify it was set. 848 // Verify it was set.
849 EXPECT_EQ(kCookieValue, GetCookies(profile, url)); 849 EXPECT_EQ(kCookieValue, GetCookies(profile, url));
850 } 850 }
851 851
852 IN_PROC_BROWSER_TEST_F(PolicyTest, PRE_DefaultCookiesSetting) { 852 IN_PROC_BROWSER_TEST_F(PolicyTest, PRE_DefaultCookiesSetting) {
853 // Verify that the cookie persists across restarts. 853 // Verify that the cookie persists across restarts.
854 EXPECT_EQ(kCookieValue, GetCookies(browser()->profile(), GURL(kURL))); 854 EXPECT_EQ(kCookieValue, GetCookies(browser()->profile(), GURL(kURL)));
855 // Now set the policy and the cookie should be gone after another restart. 855 // Now set the policy and the cookie should be gone after another restart.
856 PolicyMap policies; 856 PolicyMap policies;
857 policies.Set(key::kDefaultCookiesSetting, POLICY_LEVEL_MANDATORY, 857 policies.Set(key::kDefaultCookiesSetting,
858 POLICY_SCOPE_USER, base::Value::CreateIntegerValue(4), NULL); 858 POLICY_LEVEL_MANDATORY,
859 POLICY_SCOPE_USER,
860 new base::FundamentalValue(4),
861 NULL);
859 UpdateProviderPolicy(policies); 862 UpdateProviderPolicy(policies);
860 } 863 }
861 864
862 IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultCookiesSetting) { 865 IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultCookiesSetting) {
863 // Verify that the cookie is gone. 866 // Verify that the cookie is gone.
864 EXPECT_TRUE(GetCookies(browser()->profile(), GURL(kURL)).empty()); 867 EXPECT_TRUE(GetCookies(browser()->profile(), GURL(kURL)).empty());
865 } 868 }
866 869
867 IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultSearchProvider) { 870 IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultSearchProvider) {
868 MakeRequestFail make_request_fail("search.example"); 871 MakeRequestFail make_request_fail("search.example");
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 EXPECT_FALSE(model->CurrentMatch(NULL).destination_url.is_valid()); 982 EXPECT_FALSE(model->CurrentMatch(NULL).destination_url.is_valid());
980 EXPECT_EQ(GURL(url::kAboutBlankURL), web_contents->GetURL()); 983 EXPECT_EQ(GURL(url::kAboutBlankURL), web_contents->GetURL());
981 } 984 }
982 985
983 IN_PROC_BROWSER_TEST_F(PolicyTest, PolicyPreprocessing) { 986 IN_PROC_BROWSER_TEST_F(PolicyTest, PolicyPreprocessing) {
984 // Add an individual proxy policy value. 987 // Add an individual proxy policy value.
985 PolicyMap policies; 988 PolicyMap policies;
986 policies.Set(key::kProxyServerMode, 989 policies.Set(key::kProxyServerMode,
987 POLICY_LEVEL_MANDATORY, 990 POLICY_LEVEL_MANDATORY,
988 POLICY_SCOPE_USER, 991 POLICY_SCOPE_USER,
989 base::Value::CreateIntegerValue(3), 992 new base::FundamentalValue(3),
990 NULL); 993 NULL);
991 UpdateProviderPolicy(policies); 994 UpdateProviderPolicy(policies);
992 995
993 // It should be removed and replaced with a dictionary. 996 // It should be removed and replaced with a dictionary.
994 PolicyMap expected; 997 PolicyMap expected;
995 scoped_ptr<base::DictionaryValue> expected_value(new base::DictionaryValue); 998 scoped_ptr<base::DictionaryValue> expected_value(new base::DictionaryValue);
996 expected_value->SetInteger(key::kProxyServerMode, 3); 999 expected_value->SetInteger(key::kProxyServerMode, 3);
997 expected.Set(key::kProxySettings, 1000 expected.Set(key::kProxySettings,
998 POLICY_LEVEL_MANDATORY, 1001 POLICY_LEVEL_MANDATORY,
999 POLICY_SCOPE_USER, 1002 POLICY_SCOPE_USER,
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after
1897 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS)); 1900 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS));
1898 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE)); 1901 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE));
1899 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_DEVICES)); 1902 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_DEVICES));
1900 // Javascript is always enabled for the internal pages. 1903 // Javascript is always enabled for the internal pages.
1901 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); 1904 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL));
1902 EXPECT_TRUE(IsJavascriptEnabled(contents)); 1905 EXPECT_TRUE(IsJavascriptEnabled(contents));
1903 1906
1904 // The javascript content setting policy overrides the javascript policy. 1907 // The javascript content setting policy overrides the javascript policy.
1905 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); 1908 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL));
1906 EXPECT_FALSE(IsJavascriptEnabled(contents)); 1909 EXPECT_FALSE(IsJavascriptEnabled(contents));
1907 policies.Set(key::kDefaultJavaScriptSetting, POLICY_LEVEL_MANDATORY, 1910 policies.Set(key::kDefaultJavaScriptSetting,
1911 POLICY_LEVEL_MANDATORY,
1908 POLICY_SCOPE_USER, 1912 POLICY_SCOPE_USER,
1909 base::Value::CreateIntegerValue(CONTENT_SETTING_ALLOW), NULL); 1913 new base::FundamentalValue(CONTENT_SETTING_ALLOW),
1914 NULL);
1910 UpdateProviderPolicy(policies); 1915 UpdateProviderPolicy(policies);
1911 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); 1916 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL));
1912 EXPECT_TRUE(IsJavascriptEnabled(contents)); 1917 EXPECT_TRUE(IsJavascriptEnabled(contents));
1913 } 1918 }
1914 1919
1915 IN_PROC_BROWSER_TEST_F(PolicyTest, SavingBrowserHistoryDisabled) { 1920 IN_PROC_BROWSER_TEST_F(PolicyTest, SavingBrowserHistoryDisabled) {
1916 // Verifies that browsing history is not saved. 1921 // Verifies that browsing history is not saved.
1917 PolicyMap policies; 1922 PolicyMap policies;
1918 policies.Set(key::kSavingBrowserHistoryDisabled, 1923 policies.Set(key::kSavingBrowserHistoryDisabled,
1919 POLICY_LEVEL_MANDATORY, 1924 POLICY_LEVEL_MANDATORY,
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
2278 content::NotificationRegistrar registrar; 2283 content::NotificationRegistrar registrar;
2279 registrar.Add(&observer, 2284 registrar.Add(&observer,
2280 chrome::NOTIFICATION_APP_TERMINATING, 2285 chrome::NOTIFICATION_APP_TERMINATING,
2281 content::NotificationService::AllSources()); 2286 content::NotificationService::AllSources());
2282 2287
2283 // Set the session length limit to 3 hours. Verify that the session is not 2288 // Set the session length limit to 3 hours. Verify that the session is not
2284 // terminated. 2289 // terminated.
2285 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)) 2290 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _))
2286 .Times(0); 2291 .Times(0);
2287 PolicyMap policies; 2292 PolicyMap policies;
2288 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, 2293 policies.Set(key::kSessionLengthLimit,
2294 POLICY_LEVEL_MANDATORY,
2289 POLICY_SCOPE_USER, 2295 POLICY_SCOPE_USER,
2290 base::Value::CreateIntegerValue(kThreeHoursInMs), 2296 new base::FundamentalValue(kThreeHoursInMs),
2291 NULL); 2297 NULL);
2292 UpdateProviderPolicy(policies); 2298 UpdateProviderPolicy(policies);
2293 base::RunLoop().RunUntilIdle(); 2299 base::RunLoop().RunUntilIdle();
2294 Mock::VerifyAndClearExpectations(&observer); 2300 Mock::VerifyAndClearExpectations(&observer);
2295 2301
2296 // Decrease the session length limit to 1 hour. Verify that the session is 2302 // Decrease the session length limit to 1 hour. Verify that the session is
2297 // terminated immediately. 2303 // terminated immediately.
2298 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)); 2304 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _));
2299 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, 2305 policies.Set(key::kSessionLengthLimit,
2306 POLICY_LEVEL_MANDATORY,
2300 POLICY_SCOPE_USER, 2307 POLICY_SCOPE_USER,
2301 base::Value::CreateIntegerValue(kOneHourInMs), 2308 new base::FundamentalValue(kOneHourInMs),
2302 NULL); 2309 NULL);
2303 UpdateProviderPolicy(policies); 2310 UpdateProviderPolicy(policies);
2304 base::RunLoop().RunUntilIdle(); 2311 base::RunLoop().RunUntilIdle();
2305 Mock::VerifyAndClearExpectations(&observer); 2312 Mock::VerifyAndClearExpectations(&observer);
2306 } 2313 }
2307 2314
2308 // Disabled, see http://crbug.com/315308. 2315 // Disabled, see http://crbug.com/315308.
2309 IN_PROC_BROWSER_TEST_F(PolicyTest, 2316 IN_PROC_BROWSER_TEST_F(PolicyTest,
2310 DISABLED_PRE_WaitForInitialUserActivityUsatisfied) { 2317 DISABLED_PRE_WaitForInitialUserActivityUsatisfied) {
2311 // Indicate that the session started 2 hours ago and no user activity has 2318 // Indicate that the session started 2 hours ago and no user activity has
(...skipping 19 matching lines...) Expand all
2331 POLICY_SCOPE_USER, 2338 POLICY_SCOPE_USER,
2332 new base::FundamentalValue(true), 2339 new base::FundamentalValue(true),
2333 NULL); 2340 NULL);
2334 UpdateProviderPolicy(policies); 2341 UpdateProviderPolicy(policies);
2335 base::RunLoop().RunUntilIdle(); 2342 base::RunLoop().RunUntilIdle();
2336 2343
2337 // Set the session length limit to 1 hour. Verify that the session is not 2344 // Set the session length limit to 1 hour. Verify that the session is not
2338 // terminated. 2345 // terminated.
2339 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)) 2346 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _))
2340 .Times(0); 2347 .Times(0);
2341 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, 2348 policies.Set(key::kSessionLengthLimit,
2349 POLICY_LEVEL_MANDATORY,
2342 POLICY_SCOPE_USER, 2350 POLICY_SCOPE_USER,
2343 base::Value::CreateIntegerValue(kOneHourInMs), 2351 new base::FundamentalValue(kOneHourInMs),
2344 NULL); 2352 NULL);
2345 UpdateProviderPolicy(policies); 2353 UpdateProviderPolicy(policies);
2346 base::RunLoop().RunUntilIdle(); 2354 base::RunLoop().RunUntilIdle();
2347 Mock::VerifyAndClearExpectations(&observer); 2355 Mock::VerifyAndClearExpectations(&observer);
2348 } 2356 }
2349 2357
2350 // Disabled, see http://crbug.com/315308. 2358 // Disabled, see http://crbug.com/315308.
2351 IN_PROC_BROWSER_TEST_F(PolicyTest, 2359 IN_PROC_BROWSER_TEST_F(PolicyTest,
2352 DISABLED_PRE_WaitForInitialUserActivitySatisfied) { 2360 DISABLED_PRE_WaitForInitialUserActivitySatisfied) {
2353 // Indicate that initial user activity in this session occurred 2 hours ago. 2361 // Indicate that initial user activity in this session occurred 2 hours ago.
(...skipping 17 matching lines...) Expand all
2371 2379
2372 // Require initial user activity and set the session length limit to 3 hours. 2380 // Require initial user activity and set the session length limit to 3 hours.
2373 // Verify that the session is not terminated. 2381 // Verify that the session is not terminated.
2374 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)) 2382 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _))
2375 .Times(0); 2383 .Times(0);
2376 PolicyMap policies; 2384 PolicyMap policies;
2377 policies.Set(key::kWaitForInitialUserActivity, POLICY_LEVEL_MANDATORY, 2385 policies.Set(key::kWaitForInitialUserActivity, POLICY_LEVEL_MANDATORY,
2378 POLICY_SCOPE_USER, 2386 POLICY_SCOPE_USER,
2379 new base::FundamentalValue(true), 2387 new base::FundamentalValue(true),
2380 NULL); 2388 NULL);
2381 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, 2389 policies.Set(key::kSessionLengthLimit,
2390 POLICY_LEVEL_MANDATORY,
2382 POLICY_SCOPE_USER, 2391 POLICY_SCOPE_USER,
2383 base::Value::CreateIntegerValue(kThreeHoursInMs), 2392 new base::FundamentalValue(kThreeHoursInMs),
2384 NULL); 2393 NULL);
2385 UpdateProviderPolicy(policies); 2394 UpdateProviderPolicy(policies);
2386 base::RunLoop().RunUntilIdle(); 2395 base::RunLoop().RunUntilIdle();
2387 Mock::VerifyAndClearExpectations(&observer); 2396 Mock::VerifyAndClearExpectations(&observer);
2388 2397
2389 // Decrease the session length limit to 1 hour. Verify that the session is 2398 // Decrease the session length limit to 1 hour. Verify that the session is
2390 // terminated immediately. 2399 // terminated immediately.
2391 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)); 2400 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _));
2392 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, 2401 policies.Set(key::kSessionLengthLimit,
2402 POLICY_LEVEL_MANDATORY,
2393 POLICY_SCOPE_USER, 2403 POLICY_SCOPE_USER,
2394 base::Value::CreateIntegerValue(kOneHourInMs), 2404 new base::FundamentalValue(kOneHourInMs),
2395 NULL); 2405 NULL);
2396 UpdateProviderPolicy(policies); 2406 UpdateProviderPolicy(policies);
2397 base::RunLoop().RunUntilIdle(); 2407 base::RunLoop().RunUntilIdle();
2398 Mock::VerifyAndClearExpectations(&observer); 2408 Mock::VerifyAndClearExpectations(&observer);
2399 } 2409 }
2400 2410
2401 IN_PROC_BROWSER_TEST_F(PolicyTest, LargeCursorEnabled) { 2411 IN_PROC_BROWSER_TEST_F(PolicyTest, LargeCursorEnabled) {
2402 // Verifies that the large cursor accessibility feature can be controlled 2412 // Verifies that the large cursor accessibility feature can be controlled
2403 // through policy. 2413 // through policy.
2404 chromeos::AccessibilityManager* accessibility_manager = 2414 chromeos::AccessibilityManager* accessibility_manager =
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
2481 chromeos::MagnificationManager::Get(); 2491 chromeos::MagnificationManager::Get();
2482 2492
2483 // Manually enable the full-screen magnifier. 2493 // Manually enable the full-screen magnifier.
2484 magnification_manager->SetMagnifierType(ash::MAGNIFIER_FULL); 2494 magnification_manager->SetMagnifierType(ash::MAGNIFIER_FULL);
2485 magnification_manager->SetMagnifierEnabled(true); 2495 magnification_manager->SetMagnifierEnabled(true);
2486 EXPECT_EQ(ash::MAGNIFIER_FULL, magnification_manager->GetMagnifierType()); 2496 EXPECT_EQ(ash::MAGNIFIER_FULL, magnification_manager->GetMagnifierType());
2487 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); 2497 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled());
2488 2498
2489 // Verify that policy overrides the manual setting. 2499 // Verify that policy overrides the manual setting.
2490 PolicyMap policies; 2500 PolicyMap policies;
2491 policies.Set(key::kScreenMagnifierType, POLICY_LEVEL_MANDATORY, 2501 policies.Set(key::kScreenMagnifierType,
2502 POLICY_LEVEL_MANDATORY,
2492 POLICY_SCOPE_USER, 2503 POLICY_SCOPE_USER,
2493 base::Value::CreateIntegerValue(0), NULL); 2504 new base::FundamentalValue(0),
2505 NULL);
2494 UpdateProviderPolicy(policies); 2506 UpdateProviderPolicy(policies);
2495 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); 2507 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled());
2496 2508
2497 // Verify that the screen magnifier cannot be enabled manually anymore. 2509 // Verify that the screen magnifier cannot be enabled manually anymore.
2498 magnification_manager->SetMagnifierEnabled(true); 2510 magnification_manager->SetMagnifierEnabled(true);
2499 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); 2511 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled());
2500 } 2512 }
2501 2513
2502 IN_PROC_BROWSER_TEST_F(PolicyTest, ScreenMagnifierTypeFull) { 2514 IN_PROC_BROWSER_TEST_F(PolicyTest, ScreenMagnifierTypeFull) {
2503 // Verifies that the full-screen magnifier can be enabled through policy. 2515 // Verifies that the full-screen magnifier can be enabled through policy.
2504 chromeos::MagnificationManager* magnification_manager = 2516 chromeos::MagnificationManager* magnification_manager =
2505 chromeos::MagnificationManager::Get(); 2517 chromeos::MagnificationManager::Get();
2506 2518
2507 // Verify that the screen magnifier is initially disabled. 2519 // Verify that the screen magnifier is initially disabled.
2508 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); 2520 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled());
2509 2521
2510 // Verify that policy can enable the full-screen magnifier. 2522 // Verify that policy can enable the full-screen magnifier.
2511 PolicyMap policies; 2523 PolicyMap policies;
2512 policies.Set(key::kScreenMagnifierType, POLICY_LEVEL_MANDATORY, 2524 policies.Set(key::kScreenMagnifierType,
2525 POLICY_LEVEL_MANDATORY,
2513 POLICY_SCOPE_USER, 2526 POLICY_SCOPE_USER,
2514 base::Value::CreateIntegerValue(ash::MAGNIFIER_FULL), NULL); 2527 new base::FundamentalValue(ash::MAGNIFIER_FULL),
2528 NULL);
2515 UpdateProviderPolicy(policies); 2529 UpdateProviderPolicy(policies);
2516 EXPECT_EQ(ash::MAGNIFIER_FULL, magnification_manager->GetMagnifierType()); 2530 EXPECT_EQ(ash::MAGNIFIER_FULL, magnification_manager->GetMagnifierType());
2517 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); 2531 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled());
2518 2532
2519 // Verify that the screen magnifier cannot be disabled manually anymore. 2533 // Verify that the screen magnifier cannot be disabled manually anymore.
2520 magnification_manager->SetMagnifierEnabled(false); 2534 magnification_manager->SetMagnifierEnabled(false);
2521 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); 2535 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled());
2522 } 2536 }
2523 2537
2524 IN_PROC_BROWSER_TEST_F(PolicyTest, AccessibilityVirtualKeyboardEnabled) { 2538 IN_PROC_BROWSER_TEST_F(PolicyTest, AccessibilityVirtualKeyboardEnabled) {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
2632 2646
2633 // Redirect the test URLs to the test data directory. 2647 // Redirect the test URLs to the test data directory.
2634 RedirectHostsToTestData(kRestoredURLs, arraysize(kRestoredURLs)); 2648 RedirectHostsToTestData(kRestoredURLs, arraysize(kRestoredURLs));
2635 } 2649 }
2636 2650
2637 void HomepageIsNotNTP() { 2651 void HomepageIsNotNTP() {
2638 // Verifies that policy can set the startup pages to the homepage, when 2652 // Verifies that policy can set the startup pages to the homepage, when
2639 // the homepage is not the NTP. 2653 // the homepage is not the NTP.
2640 PolicyMap policies; 2654 PolicyMap policies;
2641 policies.Set( 2655 policies.Set(
2642 key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 2656 key::kRestoreOnStartup,
2643 base::Value::CreateIntegerValue( 2657 POLICY_LEVEL_MANDATORY,
2644 SessionStartupPref::kPrefValueHomePage), 2658 POLICY_SCOPE_USER,
2659 new base::FundamentalValue(SessionStartupPref::kPrefValueHomePage),
2645 NULL); 2660 NULL);
2646 policies.Set(key::kHomepageIsNewTabPage, 2661 policies.Set(key::kHomepageIsNewTabPage,
2647 POLICY_LEVEL_MANDATORY, 2662 POLICY_LEVEL_MANDATORY,
2648 POLICY_SCOPE_USER, 2663 POLICY_SCOPE_USER,
2649 new base::FundamentalValue(false), 2664 new base::FundamentalValue(false),
2650 NULL); 2665 NULL);
2651 policies.Set(key::kHomepageLocation, 2666 policies.Set(key::kHomepageLocation,
2652 POLICY_LEVEL_MANDATORY, 2667 POLICY_LEVEL_MANDATORY,
2653 POLICY_SCOPE_USER, 2668 POLICY_SCOPE_USER,
2654 new base::StringValue(kRestoredURLs[1]), 2669 new base::StringValue(kRestoredURLs[1]),
2655 NULL); 2670 NULL);
2656 provider_.UpdateChromePolicy(policies); 2671 provider_.UpdateChromePolicy(policies);
2657 2672
2658 expected_urls_.push_back(GURL(kRestoredURLs[1])); 2673 expected_urls_.push_back(GURL(kRestoredURLs[1]));
2659 } 2674 }
2660 2675
2661 void HomepageIsNTP() { 2676 void HomepageIsNTP() {
2662 // Verifies that policy can set the startup pages to the homepage, when 2677 // Verifies that policy can set the startup pages to the homepage, when
2663 // the homepage is the NTP. 2678 // the homepage is the NTP.
2664 PolicyMap policies; 2679 PolicyMap policies;
2665 policies.Set( 2680 policies.Set(
2666 key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 2681 key::kRestoreOnStartup,
2667 base::Value::CreateIntegerValue( 2682 POLICY_LEVEL_MANDATORY,
2668 SessionStartupPref::kPrefValueHomePage), 2683 POLICY_SCOPE_USER,
2684 new base::FundamentalValue(SessionStartupPref::kPrefValueHomePage),
2669 NULL); 2685 NULL);
2670 policies.Set(key::kHomepageIsNewTabPage, 2686 policies.Set(key::kHomepageIsNewTabPage,
2671 POLICY_LEVEL_MANDATORY, 2687 POLICY_LEVEL_MANDATORY,
2672 POLICY_SCOPE_USER, 2688 POLICY_SCOPE_USER,
2673 new base::FundamentalValue(true), 2689 new base::FundamentalValue(true),
2674 NULL); 2690 NULL);
2675 provider_.UpdateChromePolicy(policies); 2691 provider_.UpdateChromePolicy(policies);
2676 2692
2677 expected_urls_.push_back(GURL(chrome::kChromeUINewTabURL)); 2693 expected_urls_.push_back(GURL(chrome::kChromeUINewTabURL));
2678 } 2694 }
2679 2695
2680 void ListOfURLs() { 2696 void ListOfURLs() {
2681 // Verifies that policy can set the startup pages to a list of URLs. 2697 // Verifies that policy can set the startup pages to a list of URLs.
2682 base::ListValue urls; 2698 base::ListValue urls;
2683 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) { 2699 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) {
2684 urls.Append(new base::StringValue(kRestoredURLs[i])); 2700 urls.Append(new base::StringValue(kRestoredURLs[i]));
2685 expected_urls_.push_back(GURL(kRestoredURLs[i])); 2701 expected_urls_.push_back(GURL(kRestoredURLs[i]));
2686 } 2702 }
2687 PolicyMap policies; 2703 PolicyMap policies;
2688 policies.Set( 2704 policies.Set(key::kRestoreOnStartup,
2689 key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 2705 POLICY_LEVEL_MANDATORY,
2690 base::Value::CreateIntegerValue(SessionStartupPref::kPrefValueURLs), 2706 POLICY_SCOPE_USER,
2691 NULL); 2707 new base::FundamentalValue(SessionStartupPref::kPrefValueURLs),
2708 NULL);
2692 policies.Set( 2709 policies.Set(
2693 key::kRestoreOnStartupURLs, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 2710 key::kRestoreOnStartupURLs, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
2694 urls.DeepCopy(), NULL); 2711 urls.DeepCopy(), NULL);
2695 provider_.UpdateChromePolicy(policies); 2712 provider_.UpdateChromePolicy(policies);
2696 } 2713 }
2697 2714
2698 void NTP() { 2715 void NTP() {
2699 // Verifies that policy can set the startup page to the NTP. 2716 // Verifies that policy can set the startup page to the NTP.
2700 PolicyMap policies; 2717 PolicyMap policies;
2701 policies.Set( 2718 policies.Set(
2702 key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 2719 key::kRestoreOnStartup,
2703 base::Value::CreateIntegerValue(SessionStartupPref::kPrefValueNewTab), 2720 POLICY_LEVEL_MANDATORY,
2721 POLICY_SCOPE_USER,
2722 new base::FundamentalValue(SessionStartupPref::kPrefValueNewTab),
2704 NULL); 2723 NULL);
2705 provider_.UpdateChromePolicy(policies); 2724 provider_.UpdateChromePolicy(policies);
2706 expected_urls_.push_back(GURL(chrome::kChromeUINewTabURL)); 2725 expected_urls_.push_back(GURL(chrome::kChromeUINewTabURL));
2707 } 2726 }
2708 2727
2709 void Last() { 2728 void Last() {
2710 // Verifies that policy can set the startup pages to the last session. 2729 // Verifies that policy can set the startup pages to the last session.
2711 PolicyMap policies; 2730 PolicyMap policies;
2712 policies.Set( 2731 policies.Set(key::kRestoreOnStartup,
2713 key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 2732 POLICY_LEVEL_MANDATORY,
2714 base::Value::CreateIntegerValue(SessionStartupPref::kPrefValueLast), 2733 POLICY_SCOPE_USER,
2715 NULL); 2734 new base::FundamentalValue(SessionStartupPref::kPrefValueLast),
2735 NULL);
2716 provider_.UpdateChromePolicy(policies); 2736 provider_.UpdateChromePolicy(policies);
2717 // This should restore the tabs opened at PRE_RunTest below. 2737 // This should restore the tabs opened at PRE_RunTest below.
2718 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) 2738 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i)
2719 expected_urls_.push_back(GURL(kRestoredURLs[i])); 2739 expected_urls_.push_back(GURL(kRestoredURLs[i]));
2720 } 2740 }
2721 2741
2722 std::vector<GURL> expected_urls_; 2742 std::vector<GURL> expected_urls_;
2723 }; 2743 };
2724 2744
2725 IN_PROC_BROWSER_TEST_P(RestoreOnStartupPolicyTest, PRE_RunTest) { 2745 IN_PROC_BROWSER_TEST_P(RestoreOnStartupPolicyTest, PRE_RunTest) {
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
3154 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( 3174 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
3155 browser2->tab_strip_model()->GetActiveWebContents(), 3175 browser2->tab_strip_model()->GetActiveWebContents(),
3156 "domAutomationController.send(window.showModalDialog !== undefined);", 3176 "domAutomationController.send(window.showModalDialog !== undefined);",
3157 &result)); 3177 &result));
3158 EXPECT_TRUE(result); 3178 EXPECT_TRUE(result);
3159 } 3179 }
3160 3180
3161 #endif // !defined(CHROME_OS) 3181 #endif // !defined(CHROME_OS)
3162 3182
3163 } // namespace policy 3183 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/javascript_policy_handler_unittest.cc ('k') | chrome/browser/prefs/chrome_pref_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698