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 "chromeos/network/network_connection_handler.h" | 5 #include "chromeos/network/network_connection_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "chromeos/dbus/dbus_thread_manager.h" | 10 #include "chromeos/dbus/dbus_thread_manager.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 virtual ~NetworkConnectionHandlerTest() { | 31 virtual ~NetworkConnectionHandlerTest() { |
32 } | 32 } |
33 | 33 |
34 virtual void SetUp() OVERRIDE { | 34 virtual void SetUp() OVERRIDE { |
35 // Initialize DBusThreadManager with a stub implementation. | 35 // Initialize DBusThreadManager with a stub implementation. |
36 DBusThreadManager::InitializeWithStub(); | 36 DBusThreadManager::InitializeWithStub(); |
37 message_loop_.RunUntilIdle(); | 37 message_loop_.RunUntilIdle(); |
38 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface() | 38 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface() |
39 ->ClearServices(); | 39 ->ClearServices(); |
40 message_loop_.RunUntilIdle(); | 40 message_loop_.RunUntilIdle(); |
| 41 LoginState::Initialize(); |
41 network_state_handler_.reset(NetworkStateHandler::InitializeForTest()); | 42 network_state_handler_.reset(NetworkStateHandler::InitializeForTest()); |
42 network_configuration_handler_.reset( | 43 network_configuration_handler_.reset( |
43 NetworkConfigurationHandler::InitializeForTest( | 44 NetworkConfigurationHandler::InitializeForTest( |
44 network_state_handler_.get())); | 45 network_state_handler_.get())); |
45 network_connection_handler_.reset(new NetworkConnectionHandler); | 46 network_connection_handler_.reset(new NetworkConnectionHandler); |
46 network_connection_handler_->Init(network_state_handler_.get(), | 47 // TODO(stevenjb): Test integration with CertLoader using a stub or mock. |
| 48 network_connection_handler_->Init(NULL /* cert_loader */, |
| 49 network_state_handler_.get(), |
47 network_configuration_handler_.get()); | 50 network_configuration_handler_.get()); |
48 } | 51 } |
49 | 52 |
50 virtual void TearDown() OVERRIDE { | 53 virtual void TearDown() OVERRIDE { |
51 network_connection_handler_.reset(); | 54 network_connection_handler_.reset(); |
52 network_configuration_handler_.reset(); | 55 network_configuration_handler_.reset(); |
53 network_state_handler_.reset(); | 56 network_state_handler_.reset(); |
| 57 LoginState::Shutdown(); |
54 DBusThreadManager::Shutdown(); | 58 DBusThreadManager::Shutdown(); |
55 } | 59 } |
56 | 60 |
57 protected: | 61 protected: |
58 bool Configure(const std::string& json_string) { | 62 bool Configure(const std::string& json_string) { |
59 scoped_ptr<base::DictionaryValue> json_dict = | 63 scoped_ptr<base::DictionaryValue> json_dict = |
60 onc::ReadDictionaryFromJson(json_string); | 64 onc::ReadDictionaryFromJson(json_string); |
61 if (!json_dict) { | 65 if (!json_dict) { |
62 LOG(ERROR) << "Error parsing json: " << json_string; | 66 LOG(ERROR) << "Error parsing json: " << json_string; |
63 return false; | 67 return false; |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 NetworkConnectionHandlerDisconnectFailure) { | 214 NetworkConnectionHandlerDisconnectFailure) { |
211 Connect("no-network"); | 215 Connect("no-network"); |
212 EXPECT_EQ(NetworkConnectionHandler::kErrorNotFound, GetResultAndReset()); | 216 EXPECT_EQ(NetworkConnectionHandler::kErrorNotFound, GetResultAndReset()); |
213 | 217 |
214 EXPECT_TRUE(Configure(kConfigConnectable)); | 218 EXPECT_TRUE(Configure(kConfigConnectable)); |
215 Disconnect("wifi0"); | 219 Disconnect("wifi0"); |
216 EXPECT_EQ(NetworkConnectionHandler::kErrorNotConnected, GetResultAndReset()); | 220 EXPECT_EQ(NetworkConnectionHandler::kErrorNotConnected, GetResultAndReset()); |
217 } | 221 } |
218 | 222 |
219 } // namespace chromeos | 223 } // namespace chromeos |
OLD | NEW |