OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 <memory> | 5 #include <memory> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "chrome/browser/chromeos/first_run/drive_first_run_controller.h" | 12 #include "chrome/browser/chromeos/first_run/drive_first_run_controller.h" |
13 #include "chrome/browser/extensions/chrome_extension_test_notification_observer.
h" | 13 #include "chrome/browser/extensions/chrome_test_extension_loader.h" |
14 #include "chrome/browser/extensions/crx_installer.h" | |
15 #include "chrome/browser/extensions/extension_service.h" | |
16 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
17 #include "chrome/common/chrome_paths.h" | 15 #include "chrome/common/chrome_paths.h" |
18 #include "chrome/test/base/in_process_browser_test.h" | 16 #include "chrome/test/base/in_process_browser_test.h" |
19 #include "content/public/test/test_utils.h" | 17 #include "content/public/test/test_utils.h" |
20 #include "extensions/browser/extension_system.h" | |
21 #include "net/dns/mock_host_resolver.h" | 18 #include "net/dns/mock_host_resolver.h" |
22 #include "net/http/http_status_code.h" | 19 #include "net/http/http_status_code.h" |
23 #include "net/test/embedded_test_server/embedded_test_server.h" | 20 #include "net/test/embedded_test_server/embedded_test_server.h" |
24 #include "net/test/embedded_test_server/http_request.h" | 21 #include "net/test/embedded_test_server/http_request.h" |
25 #include "net/test/embedded_test_server/http_response.h" | 22 #include "net/test/embedded_test_server/http_response.h" |
26 | 23 |
27 namespace chromeos { | 24 namespace chromeos { |
28 | 25 |
29 namespace { | 26 namespace { |
30 | 27 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 // Configure the endpoint to use the test server's port. | 113 // Configure the endpoint to use the test server's port. |
117 const GURL url(kTestEndpointUrl); | 114 const GURL url(kTestEndpointUrl); |
118 GURL::Replacements replacements; | 115 GURL::Replacements replacements; |
119 std::string port(base::IntToString(embedded_test_server()->port())); | 116 std::string port(base::IntToString(embedded_test_server()->port())); |
120 replacements.SetPortStr(port); | 117 replacements.SetPortStr(port); |
121 endpoint_url_ = url.ReplaceComponents(replacements).spec(); | 118 endpoint_url_ = url.ReplaceComponents(replacements).spec(); |
122 controller_->SetAppInfoForTest(kTestAppId, endpoint_url_); | 119 controller_->SetAppInfoForTest(kTestAppId, endpoint_url_); |
123 } | 120 } |
124 | 121 |
125 void DriveFirstRunTest::InstallApp() { | 122 void DriveFirstRunTest::InstallApp() { |
126 ExtensionService* extension_service = extensions::ExtensionSystem::Get( | 123 extensions::ChromeTestExtensionLoader loader(browser()->profile()); |
127 browser()->profile())->extension_service(); | 124 ASSERT_TRUE( |
128 scoped_refptr<extensions::CrxInstaller> installer = | 125 loader.LoadExtension(test_data_dir_.AppendASCII(kTestAppCrxName))); |
129 extensions::CrxInstaller::CreateSilent(extension_service); | |
130 | |
131 installer->InstallCrx(test_data_dir_.AppendASCII(kTestAppCrxName)); | |
132 extensions::ChromeExtensionTestNotificationObserver observer(browser()); | |
133 observer.WaitForExtensionLoad(); | |
134 | |
135 ASSERT_TRUE(extension_service->GetExtensionById(kTestAppId, false)); | |
136 } | 126 } |
137 | 127 |
138 void DriveFirstRunTest::EnableOfflineMode() { | 128 void DriveFirstRunTest::EnableOfflineMode() { |
139 controller_->EnableOfflineMode(); | 129 controller_->EnableOfflineMode(); |
140 } | 130 } |
141 | 131 |
142 void DriveFirstRunTest::SetDelays(int initial_delay_secs, int timeout_secs) { | 132 void DriveFirstRunTest::SetDelays(int initial_delay_secs, int timeout_secs) { |
143 controller_->SetDelaysForTest(initial_delay_secs, timeout_secs); | 133 controller_->SetDelaysForTest(initial_delay_secs, timeout_secs); |
144 } | 134 } |
145 | 135 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 // Test that the controller times out instead of hanging forever. | 174 // Test that the controller times out instead of hanging forever. |
185 InstallApp(); | 175 InstallApp(); |
186 InitTestServer(kBadServerDirectory); | 176 InitTestServer(kBadServerDirectory); |
187 SetDelays(0, 0); | 177 SetDelays(0, 0); |
188 EnableOfflineMode(); | 178 EnableOfflineMode(); |
189 EXPECT_FALSE(WaitForFirstRunResult()); | 179 EXPECT_FALSE(WaitForFirstRunResult()); |
190 EXPECT_TRUE(timed_out()); | 180 EXPECT_TRUE(timed_out()); |
191 } | 181 } |
192 | 182 |
193 } // namespace chromeos | 183 } // namespace chromeos |
OLD | NEW |