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/login/oobe_base_test.h" | 5 #include "chrome/browser/chromeos/login/oobe_base_test.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 namespace chromeos { | 28 namespace chromeos { |
29 | 29 |
30 namespace { | 30 namespace { |
31 | 31 |
32 // Note the path name must be the same as in shill stub. | 32 // Note the path name must be the same as in shill stub. |
33 const char kStubEthernetServicePath[] = "eth1"; | 33 const char kStubEthernetServicePath[] = "eth1"; |
34 | 34 |
35 } // namespace | 35 } // namespace |
36 | 36 |
37 OobeBaseTest::OobeBaseTest() : network_portal_detector_(NULL) { | 37 OobeBaseTest::OobeBaseTest() |
| 38 : fake_gaia_(new FakeGaia()), |
| 39 network_portal_detector_(NULL) { |
38 set_exit_when_last_browser_closes(false); | 40 set_exit_when_last_browser_closes(false); |
39 } | 41 } |
40 | 42 |
41 OobeBaseTest::~OobeBaseTest() { | 43 OobeBaseTest::~OobeBaseTest() { |
42 } | 44 } |
43 | 45 |
44 void OobeBaseTest::SetUp() { | 46 void OobeBaseTest::SetUp() { |
45 base::FilePath test_data_dir; | 47 base::FilePath test_data_dir; |
46 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); | 48 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); |
47 embedded_test_server()->ServeFilesFromDirectory(test_data_dir); | 49 embedded_test_server()->ServeFilesFromDirectory(test_data_dir); |
48 embedded_test_server()->RegisterRequestHandler( | 50 embedded_test_server()->RegisterRequestHandler( |
49 base::Bind(&FakeGaia::HandleRequest, base::Unretained(&fake_gaia_))); | 51 base::Bind(&FakeGaia::HandleRequest, base::Unretained(fake_gaia_.get()))); |
50 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 52 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
51 // Stop IO thread here because no threads are allowed while | 53 // Stop IO thread here because no threads are allowed while |
52 // spawning sandbox host process. See crbug.com/322732. | 54 // spawning sandbox host process. See crbug.com/322732. |
53 embedded_test_server()->StopThread(); | 55 embedded_test_server()->StopThread(); |
54 | 56 |
55 InProcessBrowserTest::SetUp(); | 57 InProcessBrowserTest::SetUp(); |
56 } | 58 } |
57 | 59 |
58 void OobeBaseTest::SetUpInProcessBrowserTestFixture() { | 60 void OobeBaseTest::SetUpInProcessBrowserTestFixture() { |
59 host_resolver()->AddRule("*", "127.0.0.1"); | 61 host_resolver()->AddRule("*", "127.0.0.1"); |
(...skipping 29 matching lines...) Expand all Loading... |
89 const GURL& server_url = embedded_test_server()->base_url(); | 91 const GURL& server_url = embedded_test_server()->base_url(); |
90 | 92 |
91 std::string gaia_host("gaia"); | 93 std::string gaia_host("gaia"); |
92 GURL::Replacements replace_gaia_host; | 94 GURL::Replacements replace_gaia_host; |
93 replace_gaia_host.SetHostStr(gaia_host); | 95 replace_gaia_host.SetHostStr(gaia_host); |
94 GURL gaia_url = server_url.ReplaceComponents(replace_gaia_host); | 96 GURL gaia_url = server_url.ReplaceComponents(replace_gaia_host); |
95 command_line->AppendSwitchASCII(::switches::kGaiaUrl, gaia_url.spec()); | 97 command_line->AppendSwitchASCII(::switches::kGaiaUrl, gaia_url.spec()); |
96 command_line->AppendSwitchASCII(::switches::kLsoUrl, gaia_url.spec()); | 98 command_line->AppendSwitchASCII(::switches::kLsoUrl, gaia_url.spec()); |
97 command_line->AppendSwitchASCII(::switches::kGoogleApisUrl, | 99 command_line->AppendSwitchASCII(::switches::kGoogleApisUrl, |
98 gaia_url.spec()); | 100 gaia_url.spec()); |
99 fake_gaia_.Initialize(); | 101 fake_gaia_->Initialize(); |
100 } | 102 } |
101 | 103 |
102 void OobeBaseTest::SimulateNetworkOffline() { | 104 void OobeBaseTest::SimulateNetworkOffline() { |
103 NetworkPortalDetector::CaptivePortalState offline_state; | 105 NetworkPortalDetector::CaptivePortalState offline_state; |
104 offline_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_OFFLINE; | 106 offline_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_OFFLINE; |
105 network_portal_detector_->SetDetectionResultsForTesting( | 107 network_portal_detector_->SetDetectionResultsForTesting( |
106 kStubEthernetServicePath, offline_state); | 108 kStubEthernetServicePath, offline_state); |
107 network_portal_detector_->NotifyObserversForTesting(); | 109 network_portal_detector_->NotifyObserversForTesting(); |
108 } | 110 } |
109 | 111 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 | 164 |
163 WebUILoginDisplay* OobeBaseTest::GetLoginDisplay() { | 165 WebUILoginDisplay* OobeBaseTest::GetLoginDisplay() { |
164 ExistingUserController* controller = | 166 ExistingUserController* controller = |
165 ExistingUserController::current_controller(); | 167 ExistingUserController::current_controller(); |
166 CHECK(controller); | 168 CHECK(controller); |
167 return static_cast<WebUILoginDisplay*>( | 169 return static_cast<WebUILoginDisplay*>( |
168 controller->login_display()); | 170 controller->login_display()); |
169 } | 171 } |
170 | 172 |
171 } // namespace chromeos | 173 } // namespace chromeos |
OLD | NEW |