| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <memory> | 5 #include <memory> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/base64.h" | 8 #include "base/base64.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #include "chrome/browser/chromeos/app_mode/fake_cws.h" | 13 #include "chrome/browser/chromeos/app_mode/fake_cws.h" |
| 14 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" | 14 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" |
| 15 #include "chrome/browser/chromeos/login/test/app_window_waiter.h" | 15 #include "chrome/browser/chromeos/login/test/app_window_waiter.h" |
| 16 #include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h" | 16 #include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h" |
| 17 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact
ory.h" | 17 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact
ory.h" |
| 18 #include "chrome/browser/chromeos/policy/device_local_account.h" | 18 #include "chrome/browser/chromeos/policy/device_local_account.h" |
| 19 #include "chrome/browser/chromeos/policy/device_policy_builder.h" | 19 #include "chrome/browser/chromeos/policy/device_policy_builder.h" |
| 20 #include "chrome/browser/extensions/browsertest_util.h" |
| 20 #include "chrome/browser/profiles/profile_manager.h" | 21 #include "chrome/browser/profiles/profile_manager.h" |
| 21 #include "chrome/common/chrome_constants.h" | 22 #include "chrome/common/chrome_constants.h" |
| 22 #include "chrome/common/chrome_paths.h" | 23 #include "chrome/common/chrome_paths.h" |
| 23 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
| 24 #include "chrome/test/base/in_process_browser_test.h" | 25 #include "chrome/test/base/in_process_browser_test.h" |
| 25 #include "chromeos/chromeos_paths.h" | |
| 26 #include "chromeos/chromeos_switches.h" | 26 #include "chromeos/chromeos_switches.h" |
| 27 #include "chromeos/dbus/dbus_thread_manager.h" | 27 #include "chromeos/dbus/dbus_thread_manager.h" |
| 28 #include "chromeos/dbus/fake_session_manager_client.h" | 28 #include "chromeos/dbus/fake_session_manager_client.h" |
| 29 #include "chromeos/dbus/fake_shill_manager_client.h" | 29 #include "chromeos/dbus/fake_shill_manager_client.h" |
| 30 #include "components/ownership/mock_owner_key_util.h" | 30 #include "components/ownership/mock_owner_key_util.h" |
| 31 #include "extensions/browser/app_window/app_window.h" | 31 #include "extensions/browser/app_window/app_window.h" |
| 32 #include "extensions/browser/app_window/app_window_registry.h" | 32 #include "extensions/browser/app_window/app_window_registry.h" |
| 33 #include "extensions/browser/app_window/native_app_window.h" | 33 #include "extensions/browser/app_window/native_app_window.h" |
| 34 #include "extensions/common/value_builder.h" | 34 #include "extensions/common/value_builder.h" |
| 35 #include "extensions/test/extension_test_message_listener.h" | 35 #include "extensions/test/extension_test_message_listener.h" |
| 36 #include "net/dns/mock_host_resolver.h" | 36 #include "net/dns/mock_host_resolver.h" |
| 37 | 37 |
| 38 namespace em = enterprise_management; | 38 namespace em = enterprise_management; |
| 39 | 39 |
| 40 namespace chromeos { | 40 namespace chromeos { |
| 41 | 41 |
| 42 namespace { | 42 namespace { |
| 43 | 43 |
| 44 const char kTestKioskApp[] = "ggbflgnkafappblpkiflbgpmkfdpnhhe"; | 44 const char kTestKioskApp[] = "ggbflgnkafappblpkiflbgpmkfdpnhhe"; |
| 45 | 45 |
| 46 void CreateAndInitializeLocalCache() { | |
| 47 base::FilePath extension_cache_dir; | |
| 48 CHECK(PathService::Get(chromeos::DIR_DEVICE_EXTENSION_LOCAL_CACHE, | |
| 49 &extension_cache_dir)); | |
| 50 base::FilePath cache_init_file = extension_cache_dir.Append( | |
| 51 extensions::LocalExtensionCache::kCacheReadyFlagFileName); | |
| 52 EXPECT_EQ(base::WriteFile(cache_init_file, "", 0), 0); | |
| 53 } | |
| 54 | |
| 55 } // namespace | 46 } // namespace |
| 56 | 47 |
| 57 class KioskCrashRestoreTest : public InProcessBrowserTest { | 48 class KioskCrashRestoreTest : public InProcessBrowserTest { |
| 58 public: | 49 public: |
| 59 KioskCrashRestoreTest() | 50 KioskCrashRestoreTest() |
| 60 : owner_key_util_(new ownership::MockOwnerKeyUtil()), | 51 : owner_key_util_(new ownership::MockOwnerKeyUtil()), |
| 61 fake_cws_(new FakeCWS) {} | 52 fake_cws_(new FakeCWS) {} |
| 62 | 53 |
| 63 // InProcessBrowserTest | 54 // InProcessBrowserTest |
| 64 void SetUp() override { | 55 void SetUp() override { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 85 command_line->AppendSwitchASCII(switches::kLoginUser, cryptohome_id.id()); | 76 command_line->AppendSwitchASCII(switches::kLoginUser, cryptohome_id.id()); |
| 86 command_line->AppendSwitchASCII( | 77 command_line->AppendSwitchASCII( |
| 87 switches::kLoginProfile, | 78 switches::kLoginProfile, |
| 88 CryptohomeClient::GetStubSanitizedUsername(cryptohome_id)); | 79 CryptohomeClient::GetStubSanitizedUsername(cryptohome_id)); |
| 89 | 80 |
| 90 fake_cws_->Init(embedded_test_server()); | 81 fake_cws_->Init(embedded_test_server()); |
| 91 fake_cws_->SetUpdateCrx(test_app_id_, test_app_id_ + ".crx", "1.0.0"); | 82 fake_cws_->SetUpdateCrx(test_app_id_, test_app_id_ + ".crx", "1.0.0"); |
| 92 } | 83 } |
| 93 | 84 |
| 94 void SetUpOnMainThread() override { | 85 void SetUpOnMainThread() override { |
| 95 CreateAndInitializeLocalCache(); | 86 extensions::browsertest_util::CreateAndInitializeLocalCache(); |
| 96 | 87 |
| 97 embedded_test_server()->StartAcceptingConnections(); | 88 embedded_test_server()->StartAcceptingConnections(); |
| 98 } | 89 } |
| 99 | 90 |
| 100 const std::string GetTestAppUserId() const { | 91 const std::string GetTestAppUserId() const { |
| 101 return policy::GenerateDeviceLocalAccountUserId( | 92 return policy::GenerateDeviceLocalAccountUserId( |
| 102 test_app_id_, policy::DeviceLocalAccount::TYPE_KIOSK_APP); | 93 test_app_id_, policy::DeviceLocalAccount::TYPE_KIOSK_APP); |
| 103 } | 94 } |
| 104 | 95 |
| 105 const std::string& test_app_id() const { return test_app_id_; } | 96 const std::string& test_app_id() const { return test_app_id_; } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 window->GetBaseWindow()->Close(); | 185 window->GetBaseWindow()->Close(); |
| 195 | 186 |
| 196 // Wait until the app terminates if it is still running. | 187 // Wait until the app terminates if it is still running. |
| 197 if (!app_window_registry->GetAppWindowsForApp(test_app_id()).empty()) | 188 if (!app_window_registry->GetAppWindowsForApp(test_app_id()).empty()) |
| 198 base::RunLoop().Run(); | 189 base::RunLoop().Run(); |
| 199 | 190 |
| 200 EXPECT_TRUE(launch_data_check_listener.was_satisfied()); | 191 EXPECT_TRUE(launch_data_check_listener.was_satisfied()); |
| 201 } | 192 } |
| 202 | 193 |
| 203 } // namespace chromeos | 194 } // namespace chromeos |
| OLD | NEW |