Index: ui/chromeos/network/network_state_notifier_unittest.cc |
diff --git a/chrome/browser/chromeos/net/network_state_notifier_unittest.cc b/ui/chromeos/network/network_state_notifier_unittest.cc |
similarity index 69% |
copy from chrome/browser/chromeos/net/network_state_notifier_unittest.cc |
copy to ui/chromeos/network/network_state_notifier_unittest.cc |
index 82c03fac181f4662535b47fcbbafcd229adb9c3b..4d3361217509b6d8228e9b166953f031a71c0775 100644 |
--- a/chrome/browser/chromeos/net/network_state_notifier_unittest.cc |
+++ b/ui/chromeos/network/network_state_notifier_unittest.cc |
@@ -2,9 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "chrome/browser/chromeos/net/network_state_notifier.h" |
- |
-#include <memory> |
+#include "ui/chromeos/network/network_state_notifier.h" |
#include "base/macros.h" |
#include "base/run_loop.h" |
@@ -12,46 +10,35 @@ |
#include "chromeos/dbus/shill_device_client.h" |
#include "chromeos/dbus/shill_service_client.h" |
#include "chromeos/login/login_state.h" |
-#include "chromeos/network/network_connect.h" |
#include "chromeos/network/network_handler.h" |
#include "testing/gtest/include/gtest/gtest.h" |
#include "testing/platform_test.h" |
#include "third_party/cros_system_api/dbus/service_constants.h" |
+#include "ui/chromeos/network/network_connect.h" |
#include "ui/message_center/message_center.h" |
-namespace chromeos { |
-namespace test { |
- |
-namespace { |
- |
-const char kWiFi1ServicePath[] = "/service/wifi1"; |
-const char kWiFi1Guid[] = "wifi1_guid"; |
+using chromeos::DBusThreadManager; |
+using chromeos::ShillDeviceClient; |
+using chromeos::ShillServiceClient; |
-} // namespace |
+namespace ui { |
+namespace test { |
class NetworkConnectTestDelegate : public NetworkConnect::Delegate { |
public: |
- NetworkConnectTestDelegate() |
- : network_state_notifier_(new NetworkStateNotifier()) {} |
+ NetworkConnectTestDelegate() {} |
~NetworkConnectTestDelegate() override {} |
// NetworkConnect::Delegate |
void ShowNetworkConfigure(const std::string& network_id) override {} |
- void ShowNetworkSettings(const std::string& network_id) override {} |
+ void ShowNetworkSettingsForGuid(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 {} |
- void ShowNetworkConnectError(const std::string& error_name, |
- const std::string& network_id) override { |
- network_state_notifier_->ShowNetworkConnectError(error_name, network_id); |
- } |
- void ShowMobileActivationError(const std::string& network_id) override {} |
private: |
- std::unique_ptr<NetworkStateNotifier> network_state_notifier_; |
- |
DISALLOW_COPY_AND_ASSIGN(NetworkConnectTestDelegate); |
}; |
@@ -63,9 +50,9 @@ class NetworkStateNotifierTest : public testing::Test { |
void SetUp() override { |
testing::Test::SetUp(); |
DBusThreadManager::Initialize(); |
- LoginState::Initialize(); |
+ chromeos::LoginState::Initialize(); |
SetupDefaultShillState(); |
- NetworkHandler::Initialize(); |
+ chromeos::NetworkHandler::Initialize(); |
message_center::MessageCenter::Initialize(); |
base::RunLoop().RunUntilIdle(); |
network_connect_delegate_.reset(new NetworkConnectTestDelegate); |
@@ -76,8 +63,8 @@ class NetworkStateNotifierTest : public testing::Test { |
NetworkConnect::Shutdown(); |
network_connect_delegate_.reset(); |
message_center::MessageCenter::Shutdown(); |
- LoginState::Shutdown(); |
- NetworkHandler::Shutdown(); |
+ chromeos::LoginState::Shutdown(); |
+ chromeos::NetworkHandler::Shutdown(); |
DBusThreadManager::Shutdown(); |
testing::Test::TearDown(); |
} |
@@ -98,17 +85,14 @@ class NetworkStateNotifierTest : public testing::Test { |
service_test->ClearServices(); |
const bool add_to_visible = true; |
// Create a wifi network and set to online. |
- service_test->AddService(kWiFi1ServicePath, kWiFi1Guid, "wifi1", |
+ service_test->AddService("/service/wifi1", "wifi1_guid", "wifi1", |
shill::kTypeWifi, shill::kStateIdle, |
add_to_visible); |
- service_test->SetServiceProperty(kWiFi1ServicePath, |
- shill::kSecurityClassProperty, |
+ service_test->SetServiceProperty("wifi1", shill::kSecurityClassProperty, |
base::StringValue(shill::kSecurityWep)); |
- service_test->SetServiceProperty(kWiFi1ServicePath, |
- shill::kConnectableProperty, |
- base::FundamentalValue(true)); |
- service_test->SetServiceProperty(kWiFi1ServicePath, |
- shill::kPassphraseProperty, |
+ service_test->SetServiceProperty("wifi1", shill::kConnectableProperty, |
+ base::Value(true)); |
+ service_test->SetServiceProperty("wifi1", shill::kPassphraseProperty, |
base::StringValue("failure")); |
base::RunLoop().RunUntilIdle(); |
} |
@@ -121,7 +105,7 @@ class NetworkStateNotifierTest : public testing::Test { |
}; |
TEST_F(NetworkStateNotifierTest, ConnectionFailure) { |
- NetworkConnect::Get()->ConnectToNetworkId(kWiFi1Guid); |
+ NetworkConnect::Get()->ConnectToNetwork("wifi1"); |
base::RunLoop().RunUntilIdle(); |
// Failure should spawn a notification. |
message_center::MessageCenter* message_center = |
@@ -131,4 +115,4 @@ TEST_F(NetworkStateNotifierTest, ConnectionFailure) { |
} |
} // namespace test |
-} // namespace chromeos |
+} // namespace ui |