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

Unified Diff: ash/system/chromeos/network/network_state_notifier_unittest.cc

Issue 673713003: Create a NetworkConnect class and Delegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More virtual fixes Created 6 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 side-by-side diff with in-line comments
Download patch
Index: ash/system/chromeos/network/network_state_notifier_unittest.cc
diff --git a/ash/system/chromeos/network/network_state_notifier_unittest.cc b/ash/system/chromeos/network/network_state_notifier_unittest.cc
index 78299f09a7f654f36fa1e53ea6b828714cd3a721..70e7a7809e63a7afca9f849b1b61a5a67b4ed962 100644
--- a/ash/system/chromeos/network/network_state_notifier_unittest.cc
+++ b/ash/system/chromeos/network/network_state_notifier_unittest.cc
@@ -22,8 +22,10 @@
namespace {
ash::SystemTray* GetSystemTray() {
- return ash::Shell::GetPrimaryRootWindowController()->shelf()->
- status_area_widget()->system_tray();
+ return ash::Shell::GetPrimaryRootWindowController()
+ ->shelf()
+ ->status_area_widget()
+ ->system_tray();
}
} // namespace
@@ -35,21 +37,43 @@ using chromeos::ShillServiceClient;
namespace ash {
namespace test {
+class NetworkConnectTestDelegate : public NetworkConnect::Delegate {
+ public:
+ NetworkConnectTestDelegate() {}
+ ~NetworkConnectTestDelegate() override {}
+
+ // NetworkConnect::Delegate
+ void ShowNetworkConfigure(const std::string& network_id) override {}
+ void ShowNetworkSettings(const std::string& network_id) override {}
+ bool ShowEnrollNetwork(const std::string& network_id) override {
+ return false;
+ }
+ void ShowMobileSimDialog() override {}
+ void ShowMobileSetupDialog(const std::string& service_path) override {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(NetworkConnectTestDelegate);
+};
+
class NetworkStateNotifierTest : public AshTestBase {
public:
NetworkStateNotifierTest() {}
- virtual ~NetworkStateNotifierTest() {}
+ ~NetworkStateNotifierTest() override {}
- virtual void SetUp() override {
+ void SetUp() override {
DBusThreadManager::Initialize();
chromeos::LoginState::Initialize();
SetupDefaultShillState();
chromeos::NetworkHandler::Initialize();
RunAllPendingInMessageLoop();
AshTestBase::SetUp();
+ network_connect_delegate_.reset(new NetworkConnectTestDelegate);
+ NetworkConnect::Initialize(network_connect_delegate_.get());
}
- virtual void TearDown() override {
+ void TearDown() override {
+ NetworkConnect::Shutdown();
+ network_connect_delegate_.reset();
AshTestBase::TearDown();
chromeos::LoginState::Shutdown();
chromeos::NetworkHandler::Shutdown();
@@ -62,8 +86,8 @@ class NetworkStateNotifierTest : public AshTestBase {
ShillDeviceClient::TestInterface* device_test =
DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface();
device_test->ClearDevices();
- device_test->AddDevice("/device/stub_wifi_device1",
- shill::kTypeWifi, "stub_wifi_device1");
+ device_test->AddDevice("/device/stub_wifi_device1", shill::kTypeWifi,
+ "stub_wifi_device1");
device_test->AddDevice("/device/stub_cellular_device1",
shill::kTypeCellular, "stub_cellular_device1");
@@ -75,31 +99,30 @@ class NetworkStateNotifierTest : public AshTestBase {
service_test->AddService("/service/wifi1", "wifi1_guid", "wifi1",
shill::kTypeWifi, shill::kStateIdle,
add_to_visible);
- service_test->SetServiceProperty("wifi1",
- shill::kSecurityProperty,
+ service_test->SetServiceProperty("wifi1", shill::kSecurityProperty,
base::StringValue(shill::kSecurityWep));
- service_test->SetServiceProperty("wifi1",
- shill::kConnectableProperty,
+ service_test->SetServiceProperty("wifi1", shill::kConnectableProperty,
base::FundamentalValue(true));
- service_test->SetServiceProperty("wifi1",
- shill::kPassphraseProperty,
+ service_test->SetServiceProperty("wifi1", shill::kPassphraseProperty,
base::StringValue("failure"));
RunAllPendingInMessageLoop();
}
+ scoped_ptr<NetworkConnectTestDelegate> network_connect_delegate_;
+
private:
DISALLOW_COPY_AND_ASSIGN(NetworkStateNotifierTest);
};
TEST_F(NetworkStateNotifierTest, ConnectionFailure) {
EXPECT_FALSE(GetSystemTray()->HasNotificationBubble());
- ash::network_connect::ConnectToNetwork("wifi1");
+ NetworkConnect::Get()->ConnectToNetwork("wifi1");
RunAllPendingInMessageLoop();
// Failure should spawn a notification.
message_center::MessageCenter* message_center =
message_center::MessageCenter::Get();
EXPECT_TRUE(message_center->FindVisibleNotificationById(
- network_connect::kNetworkConnectNotificationId));
+ NetworkStateNotifier::kNetworkConnectNotificationId));
}
} // namespace test
« no previous file with comments | « ash/system/chromeos/network/network_state_notifier.cc ('k') | ash/system/tray/default_system_tray_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698