| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/browser/chromeos/policy/device_local_account.h" | 5 #include "chrome/browser/chromeos/policy/device_local_account.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1076 ASSERT_TRUE(browser_window); | 1076 ASSERT_TRUE(browser_window); |
| 1077 | 1077 |
| 1078 // Verify that an attempt to enter fullscreen mode is denied. | 1078 // Verify that an attempt to enter fullscreen mode is denied. |
| 1079 EXPECT_FALSE(browser_window->IsFullscreen()); | 1079 EXPECT_FALSE(browser_window->IsFullscreen()); |
| 1080 chrome::ToggleFullscreenMode(browser); | 1080 chrome::ToggleFullscreenMode(browser); |
| 1081 EXPECT_FALSE(browser_window->IsFullscreen()); | 1081 EXPECT_FALSE(browser_window->IsFullscreen()); |
| 1082 } | 1082 } |
| 1083 | 1083 |
| 1084 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, ExtensionsUncached) { | 1084 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, ExtensionsUncached) { |
| 1085 // Make it possible to force-install a hosted app and an extension. | 1085 // Make it possible to force-install a hosted app and an extension. |
| 1086 ASSERT_TRUE(embedded_test_server()->Start()); | 1086 ASSERT_TRUE(embedded_test_server()->InitializeAndListen()); |
| 1087 scoped_refptr<TestingUpdateManifestProvider> testing_update_manifest_provider( | 1087 scoped_refptr<TestingUpdateManifestProvider> testing_update_manifest_provider( |
| 1088 new TestingUpdateManifestProvider(kRelativeUpdateURL)); | 1088 new TestingUpdateManifestProvider(kRelativeUpdateURL)); |
| 1089 testing_update_manifest_provider->AddUpdate( | 1089 testing_update_manifest_provider->AddUpdate( |
| 1090 kHostedAppID, kHostedAppVersion, | 1090 kHostedAppID, kHostedAppVersion, |
| 1091 embedded_test_server()->GetURL(std::string("/") + kHostedAppCRXPath)); | 1091 embedded_test_server()->GetURL(std::string("/") + kHostedAppCRXPath)); |
| 1092 testing_update_manifest_provider->AddUpdate( | 1092 testing_update_manifest_provider->AddUpdate( |
| 1093 kGoodExtensionID, kGoodExtensionVersion, | 1093 kGoodExtensionID, kGoodExtensionVersion, |
| 1094 embedded_test_server()->GetURL(std::string("/") + kGoodExtensionCRXPath)); | 1094 embedded_test_server()->GetURL(std::string("/") + kGoodExtensionCRXPath)); |
| 1095 embedded_test_server()->RegisterRequestHandler( | 1095 embedded_test_server()->RegisterRequestHandler( |
| 1096 base::Bind(&TestingUpdateManifestProvider::HandleRequest, | 1096 base::Bind(&TestingUpdateManifestProvider::HandleRequest, |
| 1097 testing_update_manifest_provider)); | 1097 testing_update_manifest_provider)); |
| 1098 embedded_test_server()->StartAcceptingConnections(); |
| 1098 | 1099 |
| 1099 // Specify policy to force-install the hosted app and the extension. | 1100 // Specify policy to force-install the hosted app and the extension. |
| 1100 em::StringList* forcelist = device_local_account_policy_.payload() | 1101 em::StringList* forcelist = device_local_account_policy_.payload() |
| 1101 .mutable_extensioninstallforcelist()->mutable_value(); | 1102 .mutable_extensioninstallforcelist()->mutable_value(); |
| 1102 forcelist->add_entries(base::StringPrintf( | 1103 forcelist->add_entries(base::StringPrintf( |
| 1103 "%s;%s", | 1104 "%s;%s", |
| 1104 kHostedAppID, | 1105 kHostedAppID, |
| 1105 embedded_test_server()->GetURL(kRelativeUpdateURL).spec().c_str())); | 1106 embedded_test_server()->GetURL(kRelativeUpdateURL).spec().c_str())); |
| 1106 forcelist->add_entries(base::StringPrintf( | 1107 forcelist->add_entries(base::StringPrintf( |
| 1107 "%s;%s", | 1108 "%s;%s", |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1246 static void CreateFile(const base::FilePath& file, | 1247 static void CreateFile(const base::FilePath& file, |
| 1247 size_t size, | 1248 size_t size, |
| 1248 const base::Time& timestamp) { | 1249 const base::Time& timestamp) { |
| 1249 std::string data(size, 0); | 1250 std::string data(size, 0); |
| 1250 EXPECT_EQ(base::WriteFile(file, data.data(), data.size()), int(size)); | 1251 EXPECT_EQ(base::WriteFile(file, data.data(), data.size()), int(size)); |
| 1251 EXPECT_TRUE(base::TouchFile(file, timestamp, timestamp)); | 1252 EXPECT_TRUE(base::TouchFile(file, timestamp, timestamp)); |
| 1252 } | 1253 } |
| 1253 | 1254 |
| 1254 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, ExtensionCacheImplTest) { | 1255 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, ExtensionCacheImplTest) { |
| 1255 // Make it possible to force-install a hosted app and an extension. | 1256 // Make it possible to force-install a hosted app and an extension. |
| 1256 ASSERT_TRUE(embedded_test_server()->Start()); | 1257 ASSERT_TRUE(embedded_test_server()->InitializeAndListen()); |
| 1257 scoped_refptr<TestingUpdateManifestProvider> testing_update_manifest_provider( | 1258 scoped_refptr<TestingUpdateManifestProvider> testing_update_manifest_provider( |
| 1258 new TestingUpdateManifestProvider(kRelativeUpdateURL)); | 1259 new TestingUpdateManifestProvider(kRelativeUpdateURL)); |
| 1259 testing_update_manifest_provider->AddUpdate( | 1260 testing_update_manifest_provider->AddUpdate( |
| 1260 kHostedAppID, kHostedAppVersion, | 1261 kHostedAppID, kHostedAppVersion, |
| 1261 embedded_test_server()->GetURL(std::string("/") + kHostedAppCRXPath)); | 1262 embedded_test_server()->GetURL(std::string("/") + kHostedAppCRXPath)); |
| 1262 testing_update_manifest_provider->AddUpdate( | 1263 testing_update_manifest_provider->AddUpdate( |
| 1263 kGoodExtensionID, kGoodExtensionVersion, | 1264 kGoodExtensionID, kGoodExtensionVersion, |
| 1264 embedded_test_server()->GetURL(std::string("/") + kGoodExtensionCRXPath)); | 1265 embedded_test_server()->GetURL(std::string("/") + kGoodExtensionCRXPath)); |
| 1265 embedded_test_server()->RegisterRequestHandler( | 1266 embedded_test_server()->RegisterRequestHandler( |
| 1266 base::Bind(&TestingUpdateManifestProvider::HandleRequest, | 1267 base::Bind(&TestingUpdateManifestProvider::HandleRequest, |
| 1267 testing_update_manifest_provider)); | 1268 testing_update_manifest_provider)); |
| 1269 embedded_test_server()->StartAcceptingConnections(); |
| 1268 // Create and initialize local cache. | 1270 // Create and initialize local cache. |
| 1269 base::ScopedTempDir cache_dir; | 1271 base::ScopedTempDir cache_dir; |
| 1270 EXPECT_TRUE(cache_dir.CreateUniqueTempDir()); | 1272 EXPECT_TRUE(cache_dir.CreateUniqueTempDir()); |
| 1271 const base::FilePath impl_path = cache_dir.GetPath(); | 1273 const base::FilePath impl_path = cache_dir.GetPath(); |
| 1272 EXPECT_TRUE(base::CreateDirectory(impl_path)); | 1274 EXPECT_TRUE(base::CreateDirectory(impl_path)); |
| 1273 CreateFile(impl_path.Append( | 1275 CreateFile(impl_path.Append( |
| 1274 extensions::LocalExtensionCache::kCacheReadyFlagFileName), | 1276 extensions::LocalExtensionCache::kCacheReadyFlagFileName), |
| 1275 0, base::Time::Now()); | 1277 0, base::Time::Now()); |
| 1276 extensions::ExtensionCacheImpl cache_impl( | 1278 extensions::ExtensionCacheImpl cache_impl( |
| 1277 base::MakeUnique<extensions::ChromeOSExtensionCacheDelegate>(impl_path)); | 1279 base::MakeUnique<extensions::ChromeOSExtensionCacheDelegate>(impl_path)); |
| (...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2215 icu::Locale::getDefault().getLanguage()); | 2217 icu::Locale::getDefault().getLanguage()); |
| 2216 EXPECT_EQ(public_session_input_method_id_, | 2218 EXPECT_EQ(public_session_input_method_id_, |
| 2217 chromeos::input_method::InputMethodManager::Get() | 2219 chromeos::input_method::InputMethodManager::Get() |
| 2218 ->GetActiveIMEState() | 2220 ->GetActiveIMEState() |
| 2219 ->GetCurrentInputMethod() | 2221 ->GetCurrentInputMethod() |
| 2220 .id()); | 2222 .id()); |
| 2221 } | 2223 } |
| 2222 | 2224 |
| 2223 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, PolicyForExtensions) { | 2225 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, PolicyForExtensions) { |
| 2224 // Set up a test update server for the Show Managed Storage app. | 2226 // Set up a test update server for the Show Managed Storage app. |
| 2225 ASSERT_TRUE(embedded_test_server()->Start()); | 2227 ASSERT_TRUE(embedded_test_server()->InitializeAndListen()); |
| 2226 scoped_refptr<TestingUpdateManifestProvider> testing_update_manifest_provider( | 2228 scoped_refptr<TestingUpdateManifestProvider> testing_update_manifest_provider( |
| 2227 new TestingUpdateManifestProvider(kRelativeUpdateURL)); | 2229 new TestingUpdateManifestProvider(kRelativeUpdateURL)); |
| 2228 testing_update_manifest_provider->AddUpdate( | 2230 testing_update_manifest_provider->AddUpdate( |
| 2229 kShowManagedStorageID, kShowManagedStorageVersion, | 2231 kShowManagedStorageID, kShowManagedStorageVersion, |
| 2230 embedded_test_server()->GetURL(std::string("/") + | 2232 embedded_test_server()->GetURL(std::string("/") + |
| 2231 kShowManagedStorageCRXPath)); | 2233 kShowManagedStorageCRXPath)); |
| 2232 embedded_test_server()->RegisterRequestHandler( | 2234 embedded_test_server()->RegisterRequestHandler( |
| 2233 base::Bind(&TestingUpdateManifestProvider::HandleRequest, | 2235 base::Bind(&TestingUpdateManifestProvider::HandleRequest, |
| 2234 testing_update_manifest_provider)); | 2236 testing_update_manifest_provider)); |
| 2237 embedded_test_server()->StartAcceptingConnections(); |
| 2235 | 2238 |
| 2236 // Force-install the Show Managed Storage app. This app can be installed in | 2239 // Force-install the Show Managed Storage app. This app can be installed in |
| 2237 // public sessions because it's whitelisted for testing purposes. | 2240 // public sessions because it's whitelisted for testing purposes. |
| 2238 em::StringList* forcelist = device_local_account_policy_.payload() | 2241 em::StringList* forcelist = device_local_account_policy_.payload() |
| 2239 .mutable_extensioninstallforcelist()->mutable_value(); | 2242 .mutable_extensioninstallforcelist()->mutable_value(); |
| 2240 forcelist->add_entries(base::StringPrintf( | 2243 forcelist->add_entries(base::StringPrintf( |
| 2241 "%s;%s", | 2244 "%s;%s", |
| 2242 kShowManagedStorageID, | 2245 kShowManagedStorageID, |
| 2243 embedded_test_server()->GetURL(kRelativeUpdateURL).spec().c_str())); | 2246 embedded_test_server()->GetURL(kRelativeUpdateURL).spec().c_str())); |
| 2244 | 2247 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2445 ASSERT_TRUE(content::ExecuteScript(contents_, | 2448 ASSERT_TRUE(content::ExecuteScript(contents_, |
| 2446 "$('tos-accept-button').click();")); | 2449 "$('tos-accept-button').click();")); |
| 2447 | 2450 |
| 2448 WaitForSessionStart(); | 2451 WaitForSessionStart(); |
| 2449 } | 2452 } |
| 2450 | 2453 |
| 2451 INSTANTIATE_TEST_CASE_P(TermsOfServiceDownloadTestInstance, | 2454 INSTANTIATE_TEST_CASE_P(TermsOfServiceDownloadTestInstance, |
| 2452 TermsOfServiceDownloadTest, testing::Bool()); | 2455 TermsOfServiceDownloadTest, testing::Bool()); |
| 2453 | 2456 |
| 2454 } // namespace policy | 2457 } // namespace policy |
| OLD | NEW |