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 "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 } | 382 } |
383 | 383 |
384 void FlushBlacklistPolicy() { | 384 void FlushBlacklistPolicy() { |
385 // Updates of the URLBlacklist are done on IO, after building the blacklist | 385 // Updates of the URLBlacklist are done on IO, after building the blacklist |
386 // on FILE, which is initiated from IO. | 386 // on FILE, which is initiated from IO. |
387 content::RunAllPendingInMessageLoop(BrowserThread::IO); | 387 content::RunAllPendingInMessageLoop(BrowserThread::IO); |
388 content::RunAllPendingInMessageLoop(BrowserThread::FILE); | 388 content::RunAllPendingInMessageLoop(BrowserThread::FILE); |
389 content::RunAllPendingInMessageLoop(BrowserThread::IO); | 389 content::RunAllPendingInMessageLoop(BrowserThread::IO); |
390 } | 390 } |
391 | 391 |
| 392 bool ContainsVisibleElement(content::WebContents* contents, |
| 393 const std::string& id) { |
| 394 bool result; |
| 395 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
| 396 contents, |
| 397 "var elem = document.getElementById('" + id + "');" |
| 398 "domAutomationController.send(!!elem && !elem.hidden);", |
| 399 &result)); |
| 400 return result; |
| 401 } |
| 402 |
392 #if defined(OS_CHROMEOS) | 403 #if defined(OS_CHROMEOS) |
393 // Volume observer mock used by the audio policy tests. | 404 // Volume observer mock used by the audio policy tests. |
394 class TestVolumeObserver : public chromeos::AudioHandler::VolumeObserver { | 405 class TestVolumeObserver : public chromeos::AudioHandler::VolumeObserver { |
395 public: | 406 public: |
396 TestVolumeObserver() {} | 407 TestVolumeObserver() {} |
397 virtual ~TestVolumeObserver() {} | 408 virtual ~TestVolumeObserver() {} |
398 | 409 |
399 MOCK_METHOD0(OnVolumeChanged, void()); | 410 MOCK_METHOD0(OnVolumeChanged, void()); |
400 MOCK_METHOD0(OnMuteToggled, void()); | 411 MOCK_METHOD0(OnMuteToggled, void()); |
401 | 412 |
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 policies.Set(key::kDeveloperToolsDisabled, POLICY_LEVEL_MANDATORY, | 1122 policies.Set(key::kDeveloperToolsDisabled, POLICY_LEVEL_MANDATORY, |
1112 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true)); | 1123 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true)); |
1113 UpdateProviderPolicy(policies); | 1124 UpdateProviderPolicy(policies); |
1114 // The existing devtools window should have closed. | 1125 // The existing devtools window should have closed. |
1115 EXPECT_FALSE(DevToolsWindow::GetDockedInstanceForInspectedTab(contents)); | 1126 EXPECT_FALSE(DevToolsWindow::GetDockedInstanceForInspectedTab(contents)); |
1116 // And it's not possible to open it again. | 1127 // And it's not possible to open it again. |
1117 EXPECT_FALSE(chrome::ExecuteCommand(browser(), IDC_DEV_TOOLS)); | 1128 EXPECT_FALSE(chrome::ExecuteCommand(browser(), IDC_DEV_TOOLS)); |
1118 EXPECT_FALSE(DevToolsWindow::GetDockedInstanceForInspectedTab(contents)); | 1129 EXPECT_FALSE(DevToolsWindow::GetDockedInstanceForInspectedTab(contents)); |
1119 } | 1130 } |
1120 | 1131 |
| 1132 IN_PROC_BROWSER_TEST_F(PolicyTest, WebStoreIconHidden) { |
| 1133 // Verifies that the web store icons can be hidden from the new tab page. |
| 1134 |
| 1135 // Open new tab page and look for the web store icons. |
| 1136 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); |
| 1137 content::WebContents* contents = chrome::GetActiveWebContents(browser()); |
| 1138 |
| 1139 #if !defined(OS_CHROMEOS) |
| 1140 // Look for web store's app ID in the apps page. |
| 1141 EXPECT_TRUE(ContainsVisibleElement(contents, |
| 1142 "ahfgeienlihckogmohjhadlkjgocpleb")); |
| 1143 #endif |
| 1144 |
| 1145 // The next NTP has no footer. |
| 1146 if (ContainsVisibleElement(contents, "footer")) |
| 1147 EXPECT_TRUE(ContainsVisibleElement(contents, "chrome-web-store-link")); |
| 1148 |
| 1149 // Turn off the web store icons. |
| 1150 PolicyMap policies; |
| 1151 policies.Set(key::kHideWebStoreIcon, POLICY_LEVEL_MANDATORY, |
| 1152 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true)); |
| 1153 UpdateProviderPolicy(policies); |
| 1154 |
| 1155 // The web store icons should now be hidden. |
| 1156 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); |
| 1157 contents = chrome::GetActiveWebContents(browser()); |
| 1158 EXPECT_FALSE(ContainsVisibleElement(contents, |
| 1159 "ahfgeienlihckogmohjhadlkjgocpleb")); |
| 1160 EXPECT_FALSE(ContainsVisibleElement(contents, "chrome-web-store-link")); |
| 1161 } |
| 1162 |
1121 // This policy isn't available on Chrome OS. | 1163 // This policy isn't available on Chrome OS. |
1122 #if !defined(OS_CHROMEOS) | 1164 #if !defined(OS_CHROMEOS) |
1123 IN_PROC_BROWSER_TEST_F(PolicyTest, DownloadDirectory) { | 1165 IN_PROC_BROWSER_TEST_F(PolicyTest, DownloadDirectory) { |
1124 // Verifies that the download directory can be forced by policy. | 1166 // Verifies that the download directory can be forced by policy. |
1125 | 1167 |
1126 // Set the initial download directory. | 1168 // Set the initial download directory. |
1127 base::ScopedTempDir initial_dir; | 1169 base::ScopedTempDir initial_dir; |
1128 ASSERT_TRUE(initial_dir.CreateUniqueTempDir()); | 1170 ASSERT_TRUE(initial_dir.CreateUniqueTempDir()); |
1129 browser()->profile()->GetPrefs()->SetFilePath( | 1171 browser()->profile()->GetPrefs()->SetFilePath( |
1130 prefs::kDownloadDefaultDirectory, initial_dir.path()); | 1172 prefs::kDownloadDefaultDirectory, initial_dir.path()); |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1901 this)); | 1943 this)); |
1902 | 1944 |
1903 MessageLoop::current()->Run(); | 1945 MessageLoop::current()->Run(); |
1904 } | 1946 } |
1905 | 1947 |
1906 INSTANTIATE_TEST_CASE_P(MediaStreamDevicesControllerBrowserTestInstance, | 1948 INSTANTIATE_TEST_CASE_P(MediaStreamDevicesControllerBrowserTestInstance, |
1907 MediaStreamDevicesControllerBrowserTest, | 1949 MediaStreamDevicesControllerBrowserTest, |
1908 testing::Bool()); | 1950 testing::Bool()); |
1909 | 1951 |
1910 } // namespace policy | 1952 } // namespace policy |
OLD | NEW |