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

Side by Side Diff: chrome/browser/chromeos/net/network_state_notifier_unittest.cc

Issue 2434683003: Move NetworkStateNotifier and NetworkConnect from src/ui (Closed)
Patch Set: Created 4 years, 2 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
OLDNEW
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 "ui/chromeos/network/network_state_notifier.h" 5 #include "chrome/browser/chromeos/net/network_state_notifier.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "chromeos/dbus/dbus_thread_manager.h" 9 #include "chromeos/dbus/dbus_thread_manager.h"
10 #include "chromeos/dbus/shill_device_client.h" 10 #include "chromeos/dbus/shill_device_client.h"
11 #include "chromeos/dbus/shill_service_client.h" 11 #include "chromeos/dbus/shill_service_client.h"
12 #include "chromeos/login/login_state.h" 12 #include "chromeos/login/login_state.h"
13 #include "chromeos/network/network_connect.h"
13 #include "chromeos/network/network_handler.h" 14 #include "chromeos/network/network_handler.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 #include "testing/platform_test.h" 16 #include "testing/platform_test.h"
16 #include "third_party/cros_system_api/dbus/service_constants.h" 17 #include "third_party/cros_system_api/dbus/service_constants.h"
17 #include "ui/chromeos/network/network_connect.h"
18 #include "ui/message_center/message_center.h" 18 #include "ui/message_center/message_center.h"
19 19
20 using chromeos::DBusThreadManager; 20 namespace chromeos {
21 using chromeos::ShillDeviceClient;
22 using chromeos::ShillServiceClient;
23
24 namespace ui {
25 namespace test { 21 namespace test {
26 22
27 class NetworkConnectTestDelegate : public NetworkConnect::Delegate { 23 class NetworkConnectTestDelegate : public NetworkConnect::Delegate {
28 public: 24 public:
29 NetworkConnectTestDelegate() {} 25 NetworkConnectTestDelegate() {}
30 ~NetworkConnectTestDelegate() override {} 26 ~NetworkConnectTestDelegate() override {}
31 27
32 // NetworkConnect::Delegate 28 // NetworkConnect::Delegate
33 void ShowNetworkConfigure(const std::string& network_id) override {} 29 void ShowNetworkConfigure(const std::string& network_id) override {}
34 void ShowNetworkSettings(const std::string& network_id) override {} 30 void ShowNetworkSettings(const std::string& network_id) override {}
35 bool ShowEnrollNetwork(const std::string& network_id) override { 31 bool ShowEnrollNetwork(const std::string& network_id) override {
36 return false; 32 return false;
37 } 33 }
38 void ShowMobileSimDialog() override {} 34 void ShowMobileSimDialog() override {}
39 void ShowMobileSetupDialog(const std::string& service_path) override {} 35 void ShowMobileSetupDialog(const std::string& service_path) override {}
36 void ShowNetworkConnectError(const std::string& error_name,
37 const std::string& network_id) override {}
38 void ShowMobileActivationError(const std::string& network_id) override {}
40 39
41 private: 40 private:
42 DISALLOW_COPY_AND_ASSIGN(NetworkConnectTestDelegate); 41 DISALLOW_COPY_AND_ASSIGN(NetworkConnectTestDelegate);
43 }; 42 };
44 43
45 class NetworkStateNotifierTest : public testing::Test { 44 class NetworkStateNotifierTest : public testing::Test {
46 public: 45 public:
47 NetworkStateNotifierTest() {} 46 NetworkStateNotifierTest() {}
48 ~NetworkStateNotifierTest() override {} 47 ~NetworkStateNotifierTest() override {}
49 48
50 void SetUp() override { 49 void SetUp() override {
51 testing::Test::SetUp(); 50 testing::Test::SetUp();
52 DBusThreadManager::Initialize(); 51 DBusThreadManager::Initialize();
53 chromeos::LoginState::Initialize(); 52 LoginState::Initialize();
54 SetupDefaultShillState(); 53 SetupDefaultShillState();
55 chromeos::NetworkHandler::Initialize(); 54 NetworkHandler::Initialize();
56 message_center::MessageCenter::Initialize(); 55 message_center::MessageCenter::Initialize();
57 base::RunLoop().RunUntilIdle(); 56 base::RunLoop().RunUntilIdle();
58 network_connect_delegate_.reset(new NetworkConnectTestDelegate); 57 network_connect_delegate_.reset(new NetworkConnectTestDelegate);
59 NetworkConnect::Initialize(network_connect_delegate_.get()); 58 NetworkConnect::Initialize(network_connect_delegate_.get());
60 } 59 }
61 60
62 void TearDown() override { 61 void TearDown() override {
63 NetworkConnect::Shutdown(); 62 NetworkConnect::Shutdown();
64 network_connect_delegate_.reset(); 63 network_connect_delegate_.reset();
65 message_center::MessageCenter::Shutdown(); 64 message_center::MessageCenter::Shutdown();
66 chromeos::LoginState::Shutdown(); 65 LoginState::Shutdown();
67 chromeos::NetworkHandler::Shutdown(); 66 NetworkHandler::Shutdown();
68 DBusThreadManager::Shutdown(); 67 DBusThreadManager::Shutdown();
69 testing::Test::TearDown(); 68 testing::Test::TearDown();
70 } 69 }
71 70
72 protected: 71 protected:
73 void SetupDefaultShillState() { 72 void SetupDefaultShillState() {
74 base::RunLoop().RunUntilIdle(); 73 base::RunLoop().RunUntilIdle();
75 ShillDeviceClient::TestInterface* device_test = 74 ShillDeviceClient::TestInterface* device_test =
76 DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface(); 75 DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface();
77 device_test->ClearDevices(); 76 device_test->ClearDevices();
(...skipping 21 matching lines...) Expand all
99 98
100 std::unique_ptr<NetworkConnectTestDelegate> network_connect_delegate_; 99 std::unique_ptr<NetworkConnectTestDelegate> network_connect_delegate_;
101 base::MessageLoop message_loop_; 100 base::MessageLoop message_loop_;
102 101
103 private: 102 private:
104 DISALLOW_COPY_AND_ASSIGN(NetworkStateNotifierTest); 103 DISALLOW_COPY_AND_ASSIGN(NetworkStateNotifierTest);
105 }; 104 };
106 105
107 TEST_F(NetworkStateNotifierTest, ConnectionFailure) { 106 TEST_F(NetworkStateNotifierTest, ConnectionFailure) {
108 NetworkConnect::Get()->ConnectToNetwork("wifi1"); 107 NetworkConnect::Get()->ConnectToNetwork("wifi1");
109 base::RunLoop().RunUntilIdle(); 108 base::RunLoop().RunUntilIdle();
110 // Failure should spawn a notification. 109 // Failure should spawn a notification.
111 message_center::MessageCenter* message_center = 110 message_center::MessageCenter* message_center =
112 message_center::MessageCenter::Get(); 111 message_center::MessageCenter::Get();
113 EXPECT_TRUE(message_center->FindVisibleNotificationById( 112 EXPECT_TRUE(message_center->FindVisibleNotificationById(
114 NetworkStateNotifier::kNetworkConnectNotificationId)); 113 NetworkStateNotifier::kNetworkConnectNotificationId));
115 } 114 }
116 115
117 } // namespace test 116 } // namespace test
118 } // namespace ui 117 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698