Index: chromeos/network/managed_network_configuration_handler_unittest.cc |
diff --git a/chromeos/network/managed_network_configuration_handler_unittest.cc b/chromeos/network/managed_network_configuration_handler_unittest.cc |
index 3c1780952831c2c44bb476e32aa6e12ccc6c3747..c6d28abbde80a59e3ffd26e24012db9e2c548da4 100644 |
--- a/chromeos/network/managed_network_configuration_handler_unittest.cc |
+++ b/chromeos/network/managed_network_configuration_handler_unittest.cc |
@@ -14,8 +14,7 @@ |
#include "chromeos/dbus/mock_shill_profile_client.h" |
#include "chromeos/dbus/mock_shill_service_client.h" |
#include "chromeos/dbus/shill_profile_client_stub.h" |
-#include "chromeos/network/network_configuration_handler.h" |
-#include "chromeos/network/network_profile_handler_stub.h" |
+#include "chromeos/network/network_profile_handler.h" |
#include "chromeos/network/onc/onc_test_utils.h" |
#include "chromeos/network/onc/onc_utils.h" |
#include "dbus/object_path.h" |
@@ -23,6 +22,7 @@ |
#include "testing/gtest/include/gtest/gtest.h" |
#include "third_party/cros_system_api/dbus/service_constants.h" |
+using ::testing::AnyNumber; |
using ::testing::Invoke; |
using ::testing::Mock; |
using ::testing::Pointee; |
@@ -129,6 +129,19 @@ class ShillProfileTestClient { |
std::map<std::string, std::string> profile_to_user_; |
}; |
+class TestNetworkProfileHandler : public NetworkProfileHandler { |
+ public: |
+ TestNetworkProfileHandler() {} |
+ ~TestNetworkProfileHandler() {} |
+ |
+ void AddProfileForTest(const NetworkProfile& profile) { |
+ AddProfile(profile); |
+ } |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(TestNetworkProfileHandler); |
+}; |
+ |
} // namespace |
class ManagedNetworkConfigurationHandlerTest : public testing::Test { |
@@ -160,14 +173,20 @@ class ManagedNetworkConfigurationHandlerTest : public testing::Test { |
.WillByDefault(Invoke(&profiles_stub_, |
&ShillProfileTestClient::GetEntry)); |
- NetworkConfigurationHandler::Initialize(); |
- ManagedNetworkConfigurationHandler::Initialize(&stub_profile_handler_); |
+ network_profile_handler_.reset(new TestNetworkProfileHandler()); |
+ managed_network_configuration_handler_.reset( |
+ new ManagedNetworkConfigurationHandler()); |
+ managed_network_configuration_handler_->Init( |
+ NULL /* no NetworkStateHandler */, |
+ network_profile_handler_.get(), |
+ NULL /* no NetworkConfigurationHandler */); |
+ |
message_loop_.RunUntilIdle(); |
} |
virtual void TearDown() OVERRIDE { |
- ManagedNetworkConfigurationHandler::Shutdown(); |
- NetworkConfigurationHandler::Shutdown(); |
+ managed_network_configuration_handler_.reset(); |
+ network_profile_handler_.reset(); |
DBusThreadManager::Shutdown(); |
} |
@@ -179,9 +198,10 @@ class ManagedNetworkConfigurationHandlerTest : public testing::Test { |
void InitializeStandardProfiles() { |
profiles_stub_.AddProfile(kUser1ProfilePath, kUser1); |
- stub_profile_handler_.AddProfile(NetworkProfile(kUser1ProfilePath, kUser1)); |
- stub_profile_handler_.AddProfile( |
- NetworkProfile(kSharedProfilePath, std::string())); |
+ network_profile_handler_-> |
+ AddProfileForTest(NetworkProfile(kUser1ProfilePath, kUser1)); |
+ network_profile_handler_-> |
+ AddProfileForTest(NetworkProfile(kSharedProfilePath, std::string())); |
} |
void SetUpEntry(const std::string& path_to_shill_json, |
@@ -210,15 +230,17 @@ class ManagedNetworkConfigurationHandlerTest : public testing::Test { |
} |
ManagedNetworkConfigurationHandler* managed_handler() { |
- return ManagedNetworkConfigurationHandler::Get(); |
+ return managed_network_configuration_handler_.get(); |
} |
protected: |
StrictMock<MockShillManagerClient> mock_manager_client_; |
StrictMock<MockShillServiceClient> mock_service_client_; |
StrictMock<MockShillProfileClient> mock_profile_client_; |
- NetworkProfileHandlerStub stub_profile_handler_; |
ShillProfileTestClient profiles_stub_; |
+ scoped_ptr<TestNetworkProfileHandler> network_profile_handler_; |
+ scoped_ptr<ManagedNetworkConfigurationHandler> |
+ managed_network_configuration_handler_; |
MessageLoop message_loop_; |
private: |