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

Side by Side Diff: chromeos/network/geolocation_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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/geolocation_handler.h" 5 #include "chromeos/network/geolocation_handler.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/message_loop/message_loop.h"
11 #include "base/run_loop.h" 10 #include "base/run_loop.h"
12 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "base/test/scoped_task_environment.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "chromeos/dbus/dbus_thread_manager.h" 15 #include "chromeos/dbus/dbus_thread_manager.h"
16 #include "chromeos/dbus/shill_manager_client.h" 16 #include "chromeos/dbus/shill_manager_client.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 #include "third_party/cros_system_api/dbus/service_constants.h" 18 #include "third_party/cros_system_api/dbus/service_constants.h"
19 19
20 namespace chromeos { 20 namespace chromeos {
21 21
22 class GeolocationHandlerTest : public testing::Test { 22 class GeolocationHandlerTest : public testing::Test {
23 public: 23 public:
24 GeolocationHandlerTest() : manager_test_(NULL) { 24 GeolocationHandlerTest()
25 } 25 : scoped_task_environment_(
26 base::test::ScopedTaskEnvironment::MainThreadType::UI) {}
26 27
27 ~GeolocationHandlerTest() override {} 28 ~GeolocationHandlerTest() override {}
28 29
29 void SetUp() override { 30 void SetUp() override {
30 // Initialize DBusThreadManager with a stub implementation. 31 // Initialize DBusThreadManager with a stub implementation.
31 DBusThreadManager::Initialize(); 32 DBusThreadManager::Initialize();
32 // Get the test interface for manager / device. 33 // Get the test interface for manager / device.
33 manager_test_ = 34 manager_test_ =
34 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface(); 35 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface();
35 ASSERT_TRUE(manager_test_); 36 ASSERT_TRUE(manager_test_);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 properties.SetStringWithoutPathExpansion( 88 properties.SetStringWithoutPathExpansion(
88 shill::kGeoMobileCountryCodeProperty, mcc); 89 shill::kGeoMobileCountryCodeProperty, mcc);
89 properties.SetStringWithoutPathExpansion( 90 properties.SetStringWithoutPathExpansion(
90 shill::kGeoMobileNetworkCodeProperty, mnc); 91 shill::kGeoMobileNetworkCodeProperty, mnc);
91 92
92 manager_test_->AddGeoNetwork(shill::kGeoCellTowersProperty, properties); 93 manager_test_->AddGeoNetwork(shill::kGeoCellTowersProperty, properties);
93 base::RunLoop().RunUntilIdle(); 94 base::RunLoop().RunUntilIdle();
94 } 95 }
95 96
96 protected: 97 protected:
97 base::MessageLoopForUI message_loop_; 98 base::test::ScopedTaskEnvironment scoped_task_environment_;
98 std::unique_ptr<GeolocationHandler> geolocation_handler_; 99 std::unique_ptr<GeolocationHandler> geolocation_handler_;
99 ShillManagerClient::TestInterface* manager_test_; 100 ShillManagerClient::TestInterface* manager_test_ = nullptr;
100 WifiAccessPointVector wifi_access_points_; 101 WifiAccessPointVector wifi_access_points_;
101 CellTowerVector cell_towers_; 102 CellTowerVector cell_towers_;
102 103
103 private: 104 private:
104 DISALLOW_COPY_AND_ASSIGN(GeolocationHandlerTest); 105 DISALLOW_COPY_AND_ASSIGN(GeolocationHandlerTest);
105 }; 106 };
106 107
107 TEST_F(GeolocationHandlerTest, NoAccessPoints) { 108 TEST_F(GeolocationHandlerTest, NoAccessPoints) {
108 // Inititial call should return false. 109 // Inititial call should return false.
109 EXPECT_FALSE(GetWifiAccessPoints()); 110 EXPECT_FALSE(GetWifiAccessPoints());
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 EXPECT_EQ(1, wifi_access_points_[0].channel); 201 EXPECT_EQ(1, wifi_access_points_[0].channel);
201 202
202 ASSERT_EQ(2u, cell_towers_.size()); 203 ASSERT_EQ(2u, cell_towers_.size());
203 EXPECT_EQ("2", cell_towers_[1].ci); 204 EXPECT_EQ("2", cell_towers_[1].ci);
204 EXPECT_EQ("10", cell_towers_[0].lac); 205 EXPECT_EQ("10", cell_towers_[0].lac);
205 EXPECT_EQ("200", cell_towers_[1].mcc); 206 EXPECT_EQ("200", cell_towers_[1].mcc);
206 EXPECT_EQ("101", cell_towers_[0].mnc); 207 EXPECT_EQ("101", cell_towers_[0].mnc);
207 } 208 }
208 209
209 } // namespace chromeos 210 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/firewall_hole_unittest.cc ('k') | chromeos/network/network_device_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698