| 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" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 ASSERT_TRUE(embedded_test_server()->InitializeAndListen()); | 82 ASSERT_TRUE(embedded_test_server()->InitializeAndListen()); |
| 83 InProcessBrowserTest::SetUp(); | 83 InProcessBrowserTest::SetUp(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 bool SetUpUserDataDirectory() override { | 86 bool SetUpUserDataDirectory() override { |
| 87 SetUpExistingKioskApp(); | 87 SetUpExistingKioskApp(); |
| 88 return true; | 88 return true; |
| 89 } | 89 } |
| 90 | 90 |
| 91 void SetUpInProcessBrowserTestFixture() override { | 91 void SetUpInProcessBrowserTestFixture() override { |
| 92 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 93 | |
| 94 OverrideDevicePolicy(); | 92 OverrideDevicePolicy(); |
| 95 } | 93 } |
| 96 | 94 |
| 97 void SetUpCommandLine(base::CommandLine* command_line) override { | 95 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 98 const AccountId account_id = AccountId::FromUserEmail(GetTestAppUserId()); | 96 const AccountId account_id = AccountId::FromUserEmail(GetTestAppUserId()); |
| 99 const cryptohome::Identification cryptohome_id(account_id); | 97 const cryptohome::Identification cryptohome_id(account_id); |
| 100 | 98 |
| 101 command_line->AppendSwitchASCII(switches::kLoginUser, cryptohome_id.id()); | 99 command_line->AppendSwitchASCII(switches::kLoginUser, cryptohome_id.id()); |
| 102 command_line->AppendSwitchASCII( | 100 command_line->AppendSwitchASCII( |
| 103 switches::kLoginProfile, | 101 switches::kLoginProfile, |
| 104 CryptohomeClient::GetStubSanitizedUsername(cryptohome_id)); | 102 CryptohomeClient::GetStubSanitizedUsername(cryptohome_id)); |
| 105 | 103 |
| 106 fake_cws_->Init(embedded_test_server()); | 104 fake_cws_->Init(embedded_test_server()); |
| 107 fake_cws_->SetUpdateCrx(test_app_id_, test_app_id_ + ".crx", "1.0.0"); | 105 fake_cws_->SetUpdateCrx(test_app_id_, test_app_id_ + ".crx", "1.0.0"); |
| 108 } | 106 } |
| 109 | 107 |
| 110 void PreRunTestOnMainThread() override { | 108 void PreRunTestOnMainThread() override { |
| 111 termination_observer_.reset(new TerminationObserver()); | 109 termination_observer_.reset(new TerminationObserver()); |
| 112 InProcessBrowserTest::PreRunTestOnMainThread(); | 110 InProcessBrowserTest::PreRunTestOnMainThread(); |
| 113 } | 111 } |
| 114 | 112 |
| 115 void SetUpOnMainThread() override { | 113 void SetUpOnMainThread() override { |
| 116 extensions::browsertest_util::CreateAndInitializeLocalCache(); | 114 extensions::browsertest_util::CreateAndInitializeLocalCache(); |
| 117 | 115 |
| 116 host_resolver()->AddRule("*", "127.0.0.1"); |
| 118 embedded_test_server()->StartAcceptingConnections(); | 117 embedded_test_server()->StartAcceptingConnections(); |
| 119 } | 118 } |
| 120 | 119 |
| 121 const std::string GetTestAppUserId() const { | 120 const std::string GetTestAppUserId() const { |
| 122 return policy::GenerateDeviceLocalAccountUserId( | 121 return policy::GenerateDeviceLocalAccountUserId( |
| 123 test_app_id_, policy::DeviceLocalAccount::TYPE_KIOSK_APP); | 122 test_app_id_, policy::DeviceLocalAccount::TYPE_KIOSK_APP); |
| 124 } | 123 } |
| 125 | 124 |
| 126 const std::string& test_app_id() const { return test_app_id_; } | 125 const std::string& test_app_id() const { return test_app_id_; } |
| 127 | 126 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 | 189 |
| 191 IN_PROC_BROWSER_TEST_F(KioskCrashRestoreTest, AppNotInstalled) { | 190 IN_PROC_BROWSER_TEST_F(KioskCrashRestoreTest, AppNotInstalled) { |
| 192 // If app is not installed when restoring from crash, the kiosk launch is | 191 // If app is not installed when restoring from crash, the kiosk launch is |
| 193 // expected to fail, as in that case the crash occured during the app | 192 // expected to fail, as in that case the crash occured during the app |
| 194 // initialization - before the app was actually launched. | 193 // initialization - before the app was actually launched. |
| 195 EXPECT_TRUE(termination_observer_->terminated()); | 194 EXPECT_TRUE(termination_observer_->terminated()); |
| 196 EXPECT_EQ(KioskAppLaunchError::UNABLE_TO_LAUNCH, KioskAppLaunchError::Get()); | 195 EXPECT_EQ(KioskAppLaunchError::UNABLE_TO_LAUNCH, KioskAppLaunchError::Get()); |
| 197 } | 196 } |
| 198 | 197 |
| 199 } // namespace chromeos | 198 } // namespace chromeos |
| OLD | NEW |