| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/message_loop/message_loop.h" | 5 #include "device/geolocation/wifi_data_provider_chromeos.h" |
| 6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/test/scoped_task_environment.h" |
| 10 #include "chromeos/dbus/dbus_thread_manager.h" | 11 #include "chromeos/dbus/dbus_thread_manager.h" |
| 11 #include "chromeos/dbus/shill_manager_client.h" | 12 #include "chromeos/dbus/shill_manager_client.h" |
| 12 #include "chromeos/network/geolocation_handler.h" | 13 #include "chromeos/network/geolocation_handler.h" |
| 13 #include "device/geolocation/wifi_data_provider_chromeos.h" | |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "third_party/cros_system_api/dbus/service_constants.h" | 15 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 16 | 16 |
| 17 namespace device { | 17 namespace device { |
| 18 | 18 |
| 19 class GeolocationChromeOsWifiDataProviderTest : public testing::Test { | 19 class GeolocationChromeOsWifiDataProviderTest : public testing::Test { |
| 20 protected: | 20 protected: |
| 21 GeolocationChromeOsWifiDataProviderTest() {} | 21 GeolocationChromeOsWifiDataProviderTest() |
| 22 : scoped_task_environment_( |
| 23 base::test::ScopedTaskEnvironment::MainThreadType::UI) {} |
| 22 | 24 |
| 23 void SetUp() override { | 25 void SetUp() override { |
| 24 chromeos::DBusThreadManager::Initialize(); | 26 chromeos::DBusThreadManager::Initialize(); |
| 25 chromeos::NetworkHandler::Initialize(); | 27 chromeos::NetworkHandler::Initialize(); |
| 26 manager_client_ = | 28 manager_client_ = |
| 27 chromeos::DBusThreadManager::Get()->GetShillManagerClient(); | 29 chromeos::DBusThreadManager::Get()->GetShillManagerClient(); |
| 28 manager_test_ = manager_client_->GetTestInterface(); | 30 manager_test_ = manager_client_->GetTestInterface(); |
| 29 provider_ = new WifiDataProviderChromeOs(); | 31 provider_ = new WifiDataProviderChromeOs(); |
| 30 base::RunLoop().RunUntilIdle(); | 32 base::RunLoop().RunUntilIdle(); |
| 31 } | 33 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 52 channel); | 54 channel); |
| 53 properties.SetStringWithoutPathExpansion( | 55 properties.SetStringWithoutPathExpansion( |
| 54 shill::kGeoSignalStrengthProperty, strength); | 56 shill::kGeoSignalStrengthProperty, strength); |
| 55 manager_test_->AddGeoNetwork(shill::kGeoWifiAccessPointsProperty, | 57 manager_test_->AddGeoNetwork(shill::kGeoWifiAccessPointsProperty, |
| 56 properties); | 58 properties); |
| 57 } | 59 } |
| 58 } | 60 } |
| 59 base::RunLoop().RunUntilIdle(); | 61 base::RunLoop().RunUntilIdle(); |
| 60 } | 62 } |
| 61 | 63 |
| 62 base::MessageLoopForUI message_loop_; | 64 base::test::ScopedTaskEnvironment scoped_task_environment_; |
| 63 scoped_refptr<WifiDataProviderChromeOs> provider_; | 65 scoped_refptr<WifiDataProviderChromeOs> provider_; |
| 64 chromeos::ShillManagerClient* manager_client_; | 66 chromeos::ShillManagerClient* manager_client_; |
| 65 chromeos::ShillManagerClient::TestInterface* manager_test_; | 67 chromeos::ShillManagerClient::TestInterface* manager_test_; |
| 66 WifiData::AccessPointDataSet ap_data_; | 68 WifiData::AccessPointDataSet ap_data_; |
| 67 }; | 69 }; |
| 68 | 70 |
| 69 TEST_F(GeolocationChromeOsWifiDataProviderTest, NoAccessPoints) { | 71 TEST_F(GeolocationChromeOsWifiDataProviderTest, NoAccessPoints) { |
| 70 base::RunLoop().RunUntilIdle(); | 72 base::RunLoop().RunUntilIdle(); |
| 71 // Initial call to GetAccessPointData requests data and will return false. | 73 // Initial call to GetAccessPointData requests data and will return false. |
| 72 EXPECT_FALSE(GetAccessPointData()); | 74 EXPECT_FALSE(GetAccessPointData()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 90 TEST_F(GeolocationChromeOsWifiDataProviderTest, GetManyAccessPoints) { | 92 TEST_F(GeolocationChromeOsWifiDataProviderTest, GetManyAccessPoints) { |
| 91 base::RunLoop().RunUntilIdle(); | 93 base::RunLoop().RunUntilIdle(); |
| 92 EXPECT_FALSE(GetAccessPointData()); | 94 EXPECT_FALSE(GetAccessPointData()); |
| 93 | 95 |
| 94 AddAccessPoints(3, 4); | 96 AddAccessPoints(3, 4); |
| 95 EXPECT_TRUE(GetAccessPointData()); | 97 EXPECT_TRUE(GetAccessPointData()); |
| 96 ASSERT_EQ(12u, ap_data_.size()); | 98 ASSERT_EQ(12u, ap_data_.size()); |
| 97 } | 99 } |
| 98 | 100 |
| 99 } // namespace device | 101 } // namespace device |
| OLD | NEW |