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

Side by Side Diff: chromeos/network/network_state_handler_unittest.cc

Issue 2845973003: Use ScopedTaskEnvironment instead of MessageLoopForUI in chromeos tests. (Closed)
Patch Set: CR Created 3 years, 7 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 "chromeos/network/network_state_handler.h" 5 #include "chromeos/network/network_state_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 13
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/message_loop/message_loop.h"
18 #include "base/run_loop.h" 17 #include "base/run_loop.h"
18 #include "base/test/scoped_task_environment.h"
19 #include "base/values.h" 19 #include "base/values.h"
20 #include "chromeos/chromeos_switches.h" 20 #include "chromeos/chromeos_switches.h"
21 #include "chromeos/dbus/dbus_thread_manager.h" 21 #include "chromeos/dbus/dbus_thread_manager.h"
22 #include "chromeos/dbus/shill_device_client.h" 22 #include "chromeos/dbus/shill_device_client.h"
23 #include "chromeos/dbus/shill_ipconfig_client.h" 23 #include "chromeos/dbus/shill_ipconfig_client.h"
24 #include "chromeos/dbus/shill_manager_client.h" 24 #include "chromeos/dbus/shill_manager_client.h"
25 #include "chromeos/dbus/shill_profile_client.h" 25 #include "chromeos/dbus/shill_profile_client.h"
26 #include "chromeos/dbus/shill_service_client.h" 26 #include "chromeos/dbus/shill_service_client.h"
27 #include "chromeos/network/device_state.h" 27 #include "chromeos/network/device_state.h"
28 #include "chromeos/network/network_state.h" 28 #include "chromeos/network/network_state.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 DISALLOW_COPY_AND_ASSIGN(TestObserver); 191 DISALLOW_COPY_AND_ASSIGN(TestObserver);
192 }; 192 };
193 193
194 } // namespace 194 } // namespace
195 195
196 namespace chromeos { 196 namespace chromeos {
197 197
198 class NetworkStateHandlerTest : public testing::Test { 198 class NetworkStateHandlerTest : public testing::Test {
199 public: 199 public:
200 NetworkStateHandlerTest() 200 NetworkStateHandlerTest()
201 : device_test_(nullptr), 201 : scoped_task_environment_(
202 base::test::ScopedTaskEnvironment::MainThreadType::UI),
203 device_test_(nullptr),
202 manager_test_(nullptr), 204 manager_test_(nullptr),
203 profile_test_(nullptr), 205 profile_test_(nullptr),
204 service_test_(nullptr) {} 206 service_test_(nullptr) {}
205 ~NetworkStateHandlerTest() override {} 207 ~NetworkStateHandlerTest() override {}
206 208
207 void SetUp() override { 209 void SetUp() override {
208 // Initialize DBusThreadManager with a stub implementation. 210 // Initialize DBusThreadManager with a stub implementation.
209 DBusThreadManager::Initialize(); 211 DBusThreadManager::Initialize();
210 SetupDefaultShillState(); 212 SetupDefaultShillState();
211 network_state_handler_.reset(new NetworkStateHandler); 213 network_state_handler_.reset(new NetworkStateHandler);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( 290 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty(
289 dbus::ObjectPath(service_path), key, value, 291 dbus::ObjectPath(service_path), key, value,
290 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); 292 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction));
291 } 293 }
292 294
293 void GetTetherNetworkList(int limit, 295 void GetTetherNetworkList(int limit,
294 NetworkStateHandler::NetworkStateList* list) { 296 NetworkStateHandler::NetworkStateList* list) {
295 network_state_handler_->GetTetherNetworkList(limit, list); 297 network_state_handler_->GetTetherNetworkList(limit, list);
296 } 298 }
297 299
298 base::MessageLoopForUI message_loop_; 300 base::test::ScopedTaskEnvironment scoped_task_environment_;
299 std::unique_ptr<NetworkStateHandler> network_state_handler_; 301 std::unique_ptr<NetworkStateHandler> network_state_handler_;
300 std::unique_ptr<TestObserver> test_observer_; 302 std::unique_ptr<TestObserver> test_observer_;
301 ShillDeviceClient::TestInterface* device_test_; 303 ShillDeviceClient::TestInterface* device_test_;
302 ShillManagerClient::TestInterface* manager_test_; 304 ShillManagerClient::TestInterface* manager_test_;
303 ShillProfileClient::TestInterface* profile_test_; 305 ShillProfileClient::TestInterface* profile_test_;
304 ShillServiceClient::TestInterface* service_test_; 306 ShillServiceClient::TestInterface* service_test_;
305 307
306 private: 308 private:
307 DISALLOW_COPY_AND_ASSIGN(NetworkStateHandlerTest); 309 DISALLOW_COPY_AND_ASSIGN(NetworkStateHandlerTest);
308 }; 310 };
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 shill::kIPConfigProperty, 1157 shill::kIPConfigProperty,
1156 base::Value(kIPConfigPath)); 1158 base::Value(kIPConfigPath));
1157 UpdateManagerProperties(); 1159 UpdateManagerProperties();
1158 EXPECT_EQ(1, test_observer_->PropertyUpdatesForDevice( 1160 EXPECT_EQ(1, test_observer_->PropertyUpdatesForDevice(
1159 kShillManagerClientStubWifiDevice)); 1161 kShillManagerClientStubWifiDevice));
1160 EXPECT_EQ(1, test_observer_->PropertyUpdatesForService( 1162 EXPECT_EQ(1, test_observer_->PropertyUpdatesForService(
1161 kShillManagerClientStubDefaultWifi)); 1163 kShillManagerClientStubDefaultWifi));
1162 } 1164 }
1163 1165
1164 } // namespace chromeos 1166 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/network_sms_handler_unittest.cc ('k') | chromeos/network/prohibited_technologies_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698