Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: chrome/browser/chromeos/login/test/oobe_base_test.cc

Issue 299403012: Clean up shill fake implementations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/test/oobe_base_test.h" 5 #include "chrome/browser/chromeos/login/test/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"
11 #include "chrome/browser/chromeos/login/existing_user_controller.h" 11 #include "chrome/browser/chromeos/login/existing_user_controller.h"
12 #include "chrome/browser/chromeos/login/users/fake_user_manager.h" 12 #include "chrome/browser/chromeos/login/users/fake_user_manager.h"
13 #include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h" 13 #include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h"
14 #include "chrome/browser/lifetime/application_lifetime.h" 14 #include "chrome/browser/lifetime/application_lifetime.h"
15 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" 15 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
16 #include "chrome/common/chrome_paths.h" 16 #include "chrome/common/chrome_paths.h"
17 #include "chrome/common/chrome_switches.h" 17 #include "chrome/common/chrome_switches.h"
18 #include "chromeos/chromeos_switches.h" 18 #include "chromeos/chromeos_switches.h"
19 #include "chromeos/dbus/fake_shill_manager_client.h"
19 #include "content/public/browser/notification_observer.h" 20 #include "content/public/browser/notification_observer.h"
20 #include "content/public/browser/notification_registrar.h" 21 #include "content/public/browser/notification_registrar.h"
21 #include "content/public/browser/notification_service.h" 22 #include "content/public/browser/notification_service.h"
22 #include "content/public/test/browser_test_utils.h" 23 #include "content/public/test/browser_test_utils.h"
23 #include "google_apis/gaia/gaia_switches.h" 24 #include "google_apis/gaia/gaia_switches.h"
24 #include "net/dns/mock_host_resolver.h" 25 #include "net/dns/mock_host_resolver.h"
25 #include "net/test/embedded_test_server/http_request.h" 26 #include "net/test/embedded_test_server/http_request.h"
26 #include "net/test/embedded_test_server/http_response.h" 27 #include "net/test/embedded_test_server/http_response.h"
27 28
28 namespace chromeos { 29 namespace chromeos {
29 30
30 namespace {
31
32 // Note the path name must be the same as in shill stub.
33 const char kStubEthernetServicePath[] = "eth1";
34
35 } // namespace
36
37 OobeBaseTest::OobeBaseTest() 31 OobeBaseTest::OobeBaseTest()
38 : fake_gaia_(new FakeGaia()), 32 : fake_gaia_(new FakeGaia()),
39 network_portal_detector_(NULL), 33 network_portal_detector_(NULL),
40 needs_background_networking_(false) { 34 needs_background_networking_(false) {
41 set_exit_when_last_browser_closes(false); 35 set_exit_when_last_browser_closes(false);
42 set_chromeos_user_ = false; 36 set_chromeos_user_ = false;
43 } 37 }
44 38
45 OobeBaseTest::~OobeBaseTest() { 39 OobeBaseTest::~OobeBaseTest() {
46 } 40 }
(...skipping 10 matching lines...) Expand all
57 embedded_test_server()->StopThread(); 51 embedded_test_server()->StopThread();
58 52
59 ExtensionApiTest::SetUp(); 53 ExtensionApiTest::SetUp();
60 } 54 }
61 55
62 void OobeBaseTest::SetUpInProcessBrowserTestFixture() { 56 void OobeBaseTest::SetUpInProcessBrowserTestFixture() {
63 host_resolver()->AddRule("*", "127.0.0.1"); 57 host_resolver()->AddRule("*", "127.0.0.1");
64 network_portal_detector_ = new NetworkPortalDetectorTestImpl(); 58 network_portal_detector_ = new NetworkPortalDetectorTestImpl();
65 NetworkPortalDetector::InitializeForTesting(network_portal_detector_); 59 NetworkPortalDetector::InitializeForTesting(network_portal_detector_);
66 network_portal_detector_->SetDefaultNetworkPathForTesting( 60 network_portal_detector_->SetDefaultNetworkPathForTesting(
67 kStubEthernetServicePath); 61 FakeShillManagerClient::kFakeEthernetNetworkPath);
68 62
69 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); 63 ExtensionApiTest::SetUpInProcessBrowserTestFixture();
70 } 64 }
71 65
72 void OobeBaseTest::SetUpOnMainThread() { 66 void OobeBaseTest::SetUpOnMainThread() {
73 // Restart the thread as the sandbox host process has already been spawned. 67 // Restart the thread as the sandbox host process has already been spawned.
74 embedded_test_server()->RestartThreadAndListen(); 68 embedded_test_server()->RestartThreadAndListen();
75 69
76 ExtensionApiTest::SetUpOnMainThread(); 70 ExtensionApiTest::SetUpOnMainThread();
77 } 71 }
(...skipping 30 matching lines...) Expand all
108 command_line->AppendSwitchASCII(::switches::kLsoUrl, gaia_url.spec()); 102 command_line->AppendSwitchASCII(::switches::kLsoUrl, gaia_url.spec());
109 command_line->AppendSwitchASCII(::switches::kGoogleApisUrl, 103 command_line->AppendSwitchASCII(::switches::kGoogleApisUrl,
110 gaia_url.spec()); 104 gaia_url.spec());
111 fake_gaia_->Initialize(); 105 fake_gaia_->Initialize();
112 } 106 }
113 107
114 void OobeBaseTest::SimulateNetworkOffline() { 108 void OobeBaseTest::SimulateNetworkOffline() {
115 NetworkPortalDetector::CaptivePortalState offline_state; 109 NetworkPortalDetector::CaptivePortalState offline_state;
116 offline_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_OFFLINE; 110 offline_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_OFFLINE;
117 network_portal_detector_->SetDetectionResultsForTesting( 111 network_portal_detector_->SetDetectionResultsForTesting(
118 kStubEthernetServicePath, offline_state); 112 FakeShillManagerClient::kFakeEthernetNetworkPath, offline_state);
119 network_portal_detector_->NotifyObserversForTesting(); 113 network_portal_detector_->NotifyObserversForTesting();
120 } 114 }
121 115
122 base::Closure OobeBaseTest::SimulateNetworkOfflineClosure() { 116 base::Closure OobeBaseTest::SimulateNetworkOfflineClosure() {
123 return base::Bind(&OobeBaseTest::SimulateNetworkOffline, 117 return base::Bind(&OobeBaseTest::SimulateNetworkOffline,
124 base::Unretained(this)); 118 base::Unretained(this));
125 } 119 }
126 120
127 void OobeBaseTest::SimulateNetworkOnline() { 121 void OobeBaseTest::SimulateNetworkOnline() {
128 NetworkPortalDetector::CaptivePortalState online_state; 122 NetworkPortalDetector::CaptivePortalState online_state;
129 online_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE; 123 online_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE;
130 online_state.response_code = 204; 124 online_state.response_code = 204;
131 network_portal_detector_->SetDetectionResultsForTesting( 125 network_portal_detector_->SetDetectionResultsForTesting(
132 kStubEthernetServicePath, online_state); 126 FakeShillManagerClient::kFakeEthernetNetworkPath, online_state);
133 network_portal_detector_->NotifyObserversForTesting(); 127 network_portal_detector_->NotifyObserversForTesting();
134 } 128 }
135 129
136 base::Closure OobeBaseTest::SimulateNetworkOnlineClosure() { 130 base::Closure OobeBaseTest::SimulateNetworkOnlineClosure() {
137 return base::Bind(&OobeBaseTest::SimulateNetworkOnline, 131 return base::Bind(&OobeBaseTest::SimulateNetworkOnline,
138 base::Unretained(this)); 132 base::Unretained(this));
139 } 133 }
140 134
141 void OobeBaseTest::SimulateNetworkPortal() { 135 void OobeBaseTest::SimulateNetworkPortal() {
142 NetworkPortalDetector::CaptivePortalState portal_state; 136 NetworkPortalDetector::CaptivePortalState portal_state;
143 portal_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL; 137 portal_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL;
144 network_portal_detector_->SetDetectionResultsForTesting( 138 network_portal_detector_->SetDetectionResultsForTesting(
145 kStubEthernetServicePath, portal_state); 139 FakeShillManagerClient::kFakeEthernetNetworkPath, portal_state);
146 network_portal_detector_->NotifyObserversForTesting(); 140 network_portal_detector_->NotifyObserversForTesting();
147 } 141 }
148 142
149 base::Closure OobeBaseTest::SimulateNetworkPortalClosure() { 143 base::Closure OobeBaseTest::SimulateNetworkPortalClosure() {
150 return base::Bind(&OobeBaseTest::SimulateNetworkPortal, 144 return base::Bind(&OobeBaseTest::SimulateNetworkPortal,
151 base::Unretained(this)); 145 base::Unretained(this));
152 } 146 }
153 147
154 void OobeBaseTest::JsExpect(const std::string& expression) { 148 void OobeBaseTest::JsExpect(const std::string& expression) {
155 bool result; 149 bool result;
(...skipping 18 matching lines...) Expand all
174 168
175 WebUILoginDisplay* OobeBaseTest::GetLoginDisplay() { 169 WebUILoginDisplay* OobeBaseTest::GetLoginDisplay() {
176 ExistingUserController* controller = 170 ExistingUserController* controller =
177 ExistingUserController::current_controller(); 171 ExistingUserController::current_controller();
178 CHECK(controller); 172 CHECK(controller);
179 return static_cast<WebUILoginDisplay*>( 173 return static_cast<WebUILoginDisplay*>(
180 controller->login_display()); 174 controller->login_display());
181 } 175 }
182 176
183 } // namespace chromeos 177 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698