OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "chrome/browser/chromeos/cros/mock_network_library.h" | |
8 #include "chrome/browser/chromeos/login/screens/mock_error_screen.h" | 7 #include "chrome/browser/chromeos/login/screens/mock_error_screen.h" |
9 #include "chrome/browser/chromeos/login/screens/mock_screen_observer.h" | 8 #include "chrome/browser/chromeos/login/screens/mock_screen_observer.h" |
10 #include "chrome/browser/chromeos/login/screens/update_screen.h" | 9 #include "chrome/browser/chromeos/login/screens/update_screen.h" |
11 #include "chrome/browser/chromeos/login/wizard_controller.h" | 10 #include "chrome/browser/chromeos/login/wizard_controller.h" |
12 #include "chrome/browser/chromeos/login/wizard_in_process_browser_test.h" | 11 #include "chrome/browser/chromeos/login/wizard_in_process_browser_test.h" |
13 #include "chrome/browser/chromeos/net/network_portal_detector.h" | 12 #include "chrome/browser/chromeos/net/network_portal_detector.h" |
14 #include "chrome/browser/chromeos/net/network_portal_detector_stub.h" | 13 #include "chrome/browser/chromeos/net/network_portal_detector_stub.h" |
15 #include "chromeos/chromeos_switches.h" | 14 #include "chromeos/chromeos_switches.h" |
16 #include "chromeos/dbus/fake_update_engine_client.h" | 15 #include "chromeos/dbus/fake_update_engine_client.h" |
17 #include "chromeos/dbus/mock_dbus_thread_manager_without_gmock.h" | 16 #include "chromeos/dbus/mock_dbus_thread_manager_without_gmock.h" |
(...skipping 13 matching lines...) Expand all Loading... |
31 | 30 |
32 const char kStubEthernetServicePath[] = "eth0"; | 31 const char kStubEthernetServicePath[] = "eth0"; |
33 const char kStubWifiServicePath[] = "wlan0"; | 32 const char kStubWifiServicePath[] = "wlan0"; |
34 | 33 |
35 } // namespace | 34 } // namespace |
36 | 35 |
37 class UpdateScreenTest : public WizardInProcessBrowserTest { | 36 class UpdateScreenTest : public WizardInProcessBrowserTest { |
38 public: | 37 public: |
39 UpdateScreenTest() : WizardInProcessBrowserTest("update"), | 38 UpdateScreenTest() : WizardInProcessBrowserTest("update"), |
40 fake_update_engine_client_(NULL), | 39 fake_update_engine_client_(NULL), |
41 mock_network_library_(NULL), | |
42 network_portal_detector_stub_(NULL) { | 40 network_portal_detector_stub_(NULL) { |
43 } | 41 } |
44 | 42 |
45 protected: | 43 protected: |
46 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 44 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
47 MockDBusThreadManagerWithoutGMock* mock_dbus_thread_manager = | 45 MockDBusThreadManagerWithoutGMock* mock_dbus_thread_manager = |
48 new MockDBusThreadManagerWithoutGMock; | 46 new MockDBusThreadManagerWithoutGMock; |
49 DBusThreadManager::InitializeForTesting(mock_dbus_thread_manager); | 47 DBusThreadManager::InitializeForTesting(mock_dbus_thread_manager); |
50 WizardInProcessBrowserTest::SetUpInProcessBrowserTestFixture(); | 48 WizardInProcessBrowserTest::SetUpInProcessBrowserTestFixture(); |
51 cros_mock_->InitStatusAreaMocks(); | 49 cros_mock_->InitStatusAreaMocks(); |
52 cros_mock_->SetStatusAreaMocksExpectations(); | 50 cros_mock_->SetStatusAreaMocksExpectations(); |
53 | 51 |
54 fake_update_engine_client_ | 52 fake_update_engine_client_ |
55 = mock_dbus_thread_manager->fake_update_engine_client(); | 53 = mock_dbus_thread_manager->fake_update_engine_client(); |
56 | 54 |
57 mock_network_library_ = cros_mock_->mock_network_library(); | |
58 EXPECT_CALL(*mock_network_library_, LoadOncNetworks(_, _)) | |
59 .Times(AnyNumber()); | |
60 | |
61 // Setup network portal detector to return online state for both | 55 // Setup network portal detector to return online state for both |
62 // ethernet and wifi networks. Ethernet is an active network by | 56 // ethernet and wifi networks. Ethernet is an active network by |
63 // default. | 57 // default. |
64 network_portal_detector_stub_ = | 58 network_portal_detector_stub_ = |
65 static_cast<NetworkPortalDetectorStub*>( | 59 static_cast<NetworkPortalDetectorStub*>( |
66 NetworkPortalDetector::GetInstance()); | 60 NetworkPortalDetector::GetInstance()); |
67 NetworkPortalDetector::CaptivePortalState online_state; | 61 NetworkPortalDetector::CaptivePortalState online_state; |
68 online_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE; | 62 online_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE; |
69 online_state.response_code = 204; | 63 online_state.response_code = 204; |
70 SetDefaultNetworkPath(kStubEthernetServicePath); | 64 SetDefaultNetworkPath(kStubEthernetServicePath); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 network_portal_detector_stub_->SetDetectionResultsForTesting(service_path, | 106 network_portal_detector_stub_->SetDetectionResultsForTesting(service_path, |
113 state); | 107 state); |
114 } | 108 } |
115 | 109 |
116 void NotifyPortalDetectionCompleted() { | 110 void NotifyPortalDetectionCompleted() { |
117 DCHECK(network_portal_detector_stub_); | 111 DCHECK(network_portal_detector_stub_); |
118 network_portal_detector_stub_->NotifyObserversForTesting(); | 112 network_portal_detector_stub_->NotifyObserversForTesting(); |
119 } | 113 } |
120 | 114 |
121 FakeUpdateEngineClient* fake_update_engine_client_; | 115 FakeUpdateEngineClient* fake_update_engine_client_; |
122 MockNetworkLibrary* mock_network_library_; | |
123 scoped_ptr<MockScreenObserver> mock_screen_observer_; | 116 scoped_ptr<MockScreenObserver> mock_screen_observer_; |
124 scoped_ptr<MockErrorScreenActor> mock_error_screen_actor_; | 117 scoped_ptr<MockErrorScreenActor> mock_error_screen_actor_; |
125 scoped_ptr<MockErrorScreen> mock_error_screen_; | 118 scoped_ptr<MockErrorScreen> mock_error_screen_; |
126 UpdateScreen* update_screen_; | 119 UpdateScreen* update_screen_; |
127 NetworkPortalDetectorStub* network_portal_detector_stub_; | 120 NetworkPortalDetectorStub* network_portal_detector_stub_; |
128 | 121 |
129 private: | 122 private: |
130 DISALLOW_COPY_AND_ASSIGN(UpdateScreenTest); | 123 DISALLOW_COPY_AND_ASSIGN(UpdateScreenTest); |
131 }; | 124 }; |
132 | 125 |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 EXPECT_CALL(*mock_error_screen_actor_, | 342 EXPECT_CALL(*mock_error_screen_actor_, |
350 SetErrorState(ErrorScreen::ERROR_STATE_OFFLINE, std::string())) | 343 SetErrorState(ErrorScreen::ERROR_STATE_OFFLINE, std::string())) |
351 .Times(1); | 344 .Times(1); |
352 EXPECT_CALL(*mock_screen_observer_, ShowErrorScreen()) | 345 EXPECT_CALL(*mock_screen_observer_, ShowErrorScreen()) |
353 .Times(1); | 346 .Times(1); |
354 base::MessageLoop::current()->RunUntilIdle(); | 347 base::MessageLoop::current()->RunUntilIdle(); |
355 NotifyPortalDetectionCompleted(); | 348 NotifyPortalDetectionCompleted(); |
356 } | 349 } |
357 | 350 |
358 } // namespace chromeos | 351 } // namespace chromeos |
OLD | NEW |