Chromium Code Reviews| OLD | NEW |
|---|---|
| 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), | |
| 27 manager_test_(NULL) {} | |
|
stevenjb
2017/04/27 18:39:10
nit: nullptr
fdoray
2017/04/27 20:35:03
Done.
| |
| 26 | 28 |
| 27 ~GeolocationHandlerTest() override {} | 29 ~GeolocationHandlerTest() override {} |
| 28 | 30 |
| 29 void SetUp() override { | 31 void SetUp() override { |
| 30 // Initialize DBusThreadManager with a stub implementation. | 32 // Initialize DBusThreadManager with a stub implementation. |
| 31 DBusThreadManager::Initialize(); | 33 DBusThreadManager::Initialize(); |
| 32 // Get the test interface for manager / device. | 34 // Get the test interface for manager / device. |
| 33 manager_test_ = | 35 manager_test_ = |
| 34 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface(); | 36 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface(); |
| 35 ASSERT_TRUE(manager_test_); | 37 ASSERT_TRUE(manager_test_); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 properties.SetStringWithoutPathExpansion( | 89 properties.SetStringWithoutPathExpansion( |
| 88 shill::kGeoMobileCountryCodeProperty, mcc); | 90 shill::kGeoMobileCountryCodeProperty, mcc); |
| 89 properties.SetStringWithoutPathExpansion( | 91 properties.SetStringWithoutPathExpansion( |
| 90 shill::kGeoMobileNetworkCodeProperty, mnc); | 92 shill::kGeoMobileNetworkCodeProperty, mnc); |
| 91 | 93 |
| 92 manager_test_->AddGeoNetwork(shill::kGeoCellTowersProperty, properties); | 94 manager_test_->AddGeoNetwork(shill::kGeoCellTowersProperty, properties); |
| 93 base::RunLoop().RunUntilIdle(); | 95 base::RunLoop().RunUntilIdle(); |
| 94 } | 96 } |
| 95 | 97 |
| 96 protected: | 98 protected: |
| 97 base::MessageLoopForUI message_loop_; | 99 base::test::ScopedTaskEnvironment scoped_task_environment_; |
| 98 std::unique_ptr<GeolocationHandler> geolocation_handler_; | 100 std::unique_ptr<GeolocationHandler> geolocation_handler_; |
| 99 ShillManagerClient::TestInterface* manager_test_; | 101 ShillManagerClient::TestInterface* manager_test_; |
| 100 WifiAccessPointVector wifi_access_points_; | 102 WifiAccessPointVector wifi_access_points_; |
| 101 CellTowerVector cell_towers_; | 103 CellTowerVector cell_towers_; |
| 102 | 104 |
| 103 private: | 105 private: |
| 104 DISALLOW_COPY_AND_ASSIGN(GeolocationHandlerTest); | 106 DISALLOW_COPY_AND_ASSIGN(GeolocationHandlerTest); |
| 105 }; | 107 }; |
| 106 | 108 |
| 107 TEST_F(GeolocationHandlerTest, NoAccessPoints) { | 109 TEST_F(GeolocationHandlerTest, NoAccessPoints) { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 EXPECT_EQ(1, wifi_access_points_[0].channel); | 202 EXPECT_EQ(1, wifi_access_points_[0].channel); |
| 201 | 203 |
| 202 ASSERT_EQ(2u, cell_towers_.size()); | 204 ASSERT_EQ(2u, cell_towers_.size()); |
| 203 EXPECT_EQ("2", cell_towers_[1].ci); | 205 EXPECT_EQ("2", cell_towers_[1].ci); |
| 204 EXPECT_EQ("10", cell_towers_[0].lac); | 206 EXPECT_EQ("10", cell_towers_[0].lac); |
| 205 EXPECT_EQ("200", cell_towers_[1].mcc); | 207 EXPECT_EQ("200", cell_towers_[1].mcc); |
| 206 EXPECT_EQ("101", cell_towers_[0].mnc); | 208 EXPECT_EQ("101", cell_towers_[0].mnc); |
| 207 } | 209 } |
| 208 | 210 |
| 209 } // namespace chromeos | 211 } // namespace chromeos |
| OLD | NEW |