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

Side by Side Diff: chromeos/network/prohibited_technologies_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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/prohibited_technologies_handler.h" 5 #include "chromeos/network/prohibited_technologies_handler.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/json/json_reader.h" 13 #include "base/json/json_reader.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/message_loop/message_loop.h"
16 #include "base/run_loop.h" 15 #include "base/run_loop.h"
16 #include "base/test/scoped_task_environment.h"
17 #include "chromeos/dbus/dbus_thread_manager.h" 17 #include "chromeos/dbus/dbus_thread_manager.h"
18 #include "chromeos/network/managed_network_configuration_handler_impl.h" 18 #include "chromeos/network/managed_network_configuration_handler_impl.h"
19 #include "chromeos/network/network_configuration_handler.h" 19 #include "chromeos/network/network_configuration_handler.h"
20 #include "chromeos/network/network_profile_handler.h" 20 #include "chromeos/network/network_profile_handler.h"
21 #include "chromeos/network/network_state_test.h" 21 #include "chromeos/network/network_state_test.h"
22 #include "chromeos/network/onc/onc_utils.h" 22 #include "chromeos/network/onc/onc_utils.h"
23 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
24 #include "third_party/cros_system_api/dbus/service_constants.h" 24 #include "third_party/cros_system_api/dbus/service_constants.h"
25 25
26 namespace chromeos { 26 namespace chromeos {
27 27
28 class ProhibitedTechnologiesHandlerTest : public NetworkStateTest { 28 class ProhibitedTechnologiesHandlerTest : public NetworkStateTest {
29 public: 29 public:
30 ProhibitedTechnologiesHandlerTest() {} 30 ProhibitedTechnologiesHandlerTest()
31 : scoped_task_environment_(
32 base::test::ScopedTaskEnvironment::MainThreadType::UI) {}
31 33
32 void SetUp() override { 34 void SetUp() override {
33 DBusThreadManager::Initialize(); 35 DBusThreadManager::Initialize();
34 LoginState::Initialize(); 36 LoginState::Initialize();
35 37
36 NetworkStateTest::SetUp(); 38 NetworkStateTest::SetUp();
37 39
38 test_manager_client()->AddTechnology(shill::kTypeCellular, 40 test_manager_client()->AddTechnology(shill::kTypeCellular,
39 true /* enabled */); 41 true /* enabled */);
40 42
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 } 105 }
104 base::RunLoop().RunUntilIdle(); 106 base::RunLoop().RunUntilIdle();
105 } 107 }
106 108
107 std::unique_ptr<ProhibitedTechnologiesHandler> 109 std::unique_ptr<ProhibitedTechnologiesHandler>
108 prohibited_technologies_handler_; 110 prohibited_technologies_handler_;
109 std::unique_ptr<NetworkConfigurationHandler> network_config_handler_; 111 std::unique_ptr<NetworkConfigurationHandler> network_config_handler_;
110 std::unique_ptr<ManagedNetworkConfigurationHandlerImpl> 112 std::unique_ptr<ManagedNetworkConfigurationHandlerImpl>
111 managed_config_handler_; 113 managed_config_handler_;
112 std::unique_ptr<NetworkProfileHandler> network_profile_handler_; 114 std::unique_ptr<NetworkProfileHandler> network_profile_handler_;
113 base::MessageLoopForUI message_loop_; 115 base::test::ScopedTaskEnvironment scoped_task_environment_;
114 base::DictionaryValue global_config_disable_wifi; 116 base::DictionaryValue global_config_disable_wifi;
115 base::DictionaryValue global_config_disable_wifi_and_cell; 117 base::DictionaryValue global_config_disable_wifi_and_cell;
116 118
117 private: 119 private:
118 DISALLOW_COPY_AND_ASSIGN(ProhibitedTechnologiesHandlerTest); 120 DISALLOW_COPY_AND_ASSIGN(ProhibitedTechnologiesHandlerTest);
119 }; 121 };
120 122
121 TEST_F(ProhibitedTechnologiesHandlerTest, 123 TEST_F(ProhibitedTechnologiesHandlerTest,
122 ProhibitedTechnologiesAllowedLoginScreen) { 124 ProhibitedTechnologiesAllowedLoginScreen) {
123 EXPECT_TRUE( 125 EXPECT_TRUE(
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 network_state_handler()->SetTechnologyEnabled( 173 network_state_handler()->SetTechnologyEnabled(
172 NetworkTypePattern::Cellular(), true, network_handler::ErrorCallback()); 174 NetworkTypePattern::Cellular(), true, network_handler::ErrorCallback());
173 base::RunLoop().RunUntilIdle(); 175 base::RunLoop().RunUntilIdle();
174 EXPECT_FALSE( 176 EXPECT_FALSE(
175 network_state_handler()->IsTechnologyEnabled(NetworkTypePattern::WiFi())); 177 network_state_handler()->IsTechnologyEnabled(NetworkTypePattern::WiFi()));
176 EXPECT_TRUE(network_state_handler()->IsTechnologyEnabled( 178 EXPECT_TRUE(network_state_handler()->IsTechnologyEnabled(
177 NetworkTypePattern::Cellular())); 179 NetworkTypePattern::Cellular()));
178 } 180 }
179 181
180 } // namespace chromeos 182 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/network_state_handler_unittest.cc ('k') | chromeos/network/shill_property_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698