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 "base/run_loop.h" | 6 #include "base/run_loop.h" |
6 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
7 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
8 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
9 #include "chromeos/dbus/dbus_thread_manager.h" | 10 #include "chromeos/dbus/dbus_thread_manager.h" |
10 #include "chromeos/dbus/shill_manager_client.h" | 11 #include "chromeos/dbus/shill_manager_client.h" |
11 #include "chromeos/network/geolocation_handler.h" | 12 #include "chromeos/network/geolocation_handler.h" |
12 #include "content/browser/geolocation/wifi_data_provider_chromeos.h" | 13 #include "device/geolocation/wifi_data_provider_chromeos.h" |
13 #include "content/public/test/test_browser_thread_bundle.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 content { | 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 } | 22 } |
23 | 23 |
24 void SetUp() override { | 24 void SetUp() override { |
25 chromeos::DBusThreadManager::Initialize(); | 25 chromeos::DBusThreadManager::Initialize(); |
26 chromeos::NetworkHandler::Initialize(); | 26 chromeos::NetworkHandler::Initialize(); |
27 manager_client_ = | 27 manager_client_ = |
(...skipping 27 matching lines...) Expand all Loading... |
55 properties.SetStringWithoutPathExpansion( | 55 properties.SetStringWithoutPathExpansion( |
56 shill::kGeoChannelProperty, channel); | 56 shill::kGeoChannelProperty, channel); |
57 properties.SetStringWithoutPathExpansion( | 57 properties.SetStringWithoutPathExpansion( |
58 shill::kGeoSignalStrengthProperty, strength); | 58 shill::kGeoSignalStrengthProperty, strength); |
59 manager_test_->AddGeoNetwork(shill::kTypeWifi, properties); | 59 manager_test_->AddGeoNetwork(shill::kTypeWifi, properties); |
60 } | 60 } |
61 } | 61 } |
62 base::RunLoop().RunUntilIdle(); | 62 base::RunLoop().RunUntilIdle(); |
63 } | 63 } |
64 | 64 |
65 TestBrowserThreadBundle thread_bundle_; | 65 base::MessageLoopForUI message_loop_; |
66 scoped_refptr<WifiDataProviderChromeOs> provider_; | 66 scoped_refptr<WifiDataProviderChromeOs> provider_; |
67 chromeos::ShillManagerClient* manager_client_; | 67 chromeos::ShillManagerClient* manager_client_; |
68 chromeos::ShillManagerClient::TestInterface* manager_test_; | 68 chromeos::ShillManagerClient::TestInterface* manager_test_; |
69 WifiData::AccessPointDataSet ap_data_; | 69 WifiData::AccessPointDataSet ap_data_; |
70 }; | 70 }; |
71 | 71 |
72 TEST_F(GeolocationChromeOsWifiDataProviderTest, NoAccessPoints) { | 72 TEST_F(GeolocationChromeOsWifiDataProviderTest, NoAccessPoints) { |
73 base::RunLoop().RunUntilIdle(); | 73 base::RunLoop().RunUntilIdle(); |
74 // Initial call to GetAccessPointData requests data and will return false. | 74 // Initial call to GetAccessPointData requests data and will return false. |
75 EXPECT_FALSE(GetAccessPointData()); | 75 EXPECT_FALSE(GetAccessPointData()); |
(...skipping 16 matching lines...) Expand all Loading... |
92 | 92 |
93 TEST_F(GeolocationChromeOsWifiDataProviderTest, GetManyAccessPoints) { | 93 TEST_F(GeolocationChromeOsWifiDataProviderTest, GetManyAccessPoints) { |
94 base::RunLoop().RunUntilIdle(); | 94 base::RunLoop().RunUntilIdle(); |
95 EXPECT_FALSE(GetAccessPointData()); | 95 EXPECT_FALSE(GetAccessPointData()); |
96 | 96 |
97 AddAccessPoints(3, 4); | 97 AddAccessPoints(3, 4); |
98 EXPECT_TRUE(GetAccessPointData()); | 98 EXPECT_TRUE(GetAccessPointData()); |
99 ASSERT_EQ(12u, ap_data_.size()); | 99 ASSERT_EQ(12u, ap_data_.size()); |
100 } | 100 } |
101 | 101 |
102 } // namespace content | 102 } // namespace device |
OLD | NEW |