OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/geolocation/wifi_data_provider_linux.h" | 5 #include "content/browser/geolocation/wifi_data_provider_linux.h" |
6 | 6 |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 // Create a mock proxy that behaves as NetworkManager. | 33 // Create a mock proxy that behaves as NetworkManager. |
34 mock_network_manager_proxy_ = | 34 mock_network_manager_proxy_ = |
35 new dbus::MockObjectProxy( | 35 new dbus::MockObjectProxy( |
36 mock_bus_.get(), | 36 mock_bus_.get(), |
37 "org.freedesktop.NetworkManager", | 37 "org.freedesktop.NetworkManager", |
38 dbus::ObjectPath("/org/freedesktop/NetworkManager")); | 38 dbus::ObjectPath("/org/freedesktop/NetworkManager")); |
39 // Set an expectation so mock_network_manager_proxy_'s | 39 // Set an expectation so mock_network_manager_proxy_'s |
40 // CallMethodAndBlock() will use CreateNetworkManagerProxyResponse() | 40 // CallMethodAndBlock() will use CreateNetworkManagerProxyResponse() |
41 // to return responses. | 41 // to return responses. |
42 EXPECT_CALL(*mock_network_manager_proxy_, | 42 EXPECT_CALL(*mock_network_manager_proxy_.get(), |
43 MockCallMethodAndBlock(_, _)) | 43 MockCallMethodAndBlock(_, _)) |
44 .WillRepeatedly(Invoke( | 44 .WillRepeatedly(Invoke(this, |
45 this, | 45 &GeolocationWifiDataProviderLinuxTest:: |
46 &GeolocationWifiDataProviderLinuxTest:: | 46 CreateNetworkManagerProxyResponse)); |
47 CreateNetworkManagerProxyResponse)); | |
48 | 47 |
49 // Create a mock proxy that behaves as NetworkManager/Devices/0. | 48 // Create a mock proxy that behaves as NetworkManager/Devices/0. |
50 mock_device_proxy_ = | 49 mock_device_proxy_ = |
51 new dbus::MockObjectProxy( | 50 new dbus::MockObjectProxy( |
52 mock_bus_.get(), | 51 mock_bus_.get(), |
53 "org.freedesktop.NetworkManager", | 52 "org.freedesktop.NetworkManager", |
54 dbus::ObjectPath("/org/freedesktop/NetworkManager/Devices/0")); | 53 dbus::ObjectPath("/org/freedesktop/NetworkManager/Devices/0")); |
55 EXPECT_CALL(*mock_device_proxy_, | 54 EXPECT_CALL(*mock_device_proxy_.get(), MockCallMethodAndBlock(_, _)) |
56 MockCallMethodAndBlock(_, _)) | |
57 .WillRepeatedly(Invoke( | 55 .WillRepeatedly(Invoke( |
58 this, | 56 this, |
59 &GeolocationWifiDataProviderLinuxTest::CreateDeviceProxyResponse)); | 57 &GeolocationWifiDataProviderLinuxTest::CreateDeviceProxyResponse)); |
60 | 58 |
61 // Create a mock proxy that behaves as NetworkManager/AccessPoint/0. | 59 // Create a mock proxy that behaves as NetworkManager/AccessPoint/0. |
62 mock_access_point_proxy_ = | 60 mock_access_point_proxy_ = |
63 new dbus::MockObjectProxy( | 61 new dbus::MockObjectProxy( |
64 mock_bus_.get(), | 62 mock_bus_.get(), |
65 "org.freedesktop.NetworkManager", | 63 "org.freedesktop.NetworkManager", |
66 dbus::ObjectPath("/org/freedesktop/NetworkManager/AccessPoint/0")); | 64 dbus::ObjectPath("/org/freedesktop/NetworkManager/AccessPoint/0")); |
67 EXPECT_CALL(*mock_access_point_proxy_, | 65 EXPECT_CALL(*mock_access_point_proxy_.get(), MockCallMethodAndBlock(_, _)) |
68 MockCallMethodAndBlock(_, _)) | 66 .WillRepeatedly(Invoke(this, |
69 .WillRepeatedly(Invoke( | 67 &GeolocationWifiDataProviderLinuxTest:: |
70 this, | 68 CreateAccessPointProxyResponse)); |
71 &GeolocationWifiDataProviderLinuxTest:: | |
72 CreateAccessPointProxyResponse)); | |
73 | 69 |
74 // Set an expectation so mock_bus_'s GetObjectProxy() for the given | 70 // Set an expectation so mock_bus_'s GetObjectProxy() for the given |
75 // service name and the object path will return | 71 // service name and the object path will return |
76 // mock_network_manager_proxy_. | 72 // mock_network_manager_proxy_. |
77 EXPECT_CALL(*mock_bus_, GetObjectProxy( | 73 EXPECT_CALL( |
78 "org.freedesktop.NetworkManager", | 74 *mock_bus_.get(), |
79 dbus::ObjectPath("/org/freedesktop/NetworkManager"))) | 75 GetObjectProxy("org.freedesktop.NetworkManager", |
| 76 dbus::ObjectPath("/org/freedesktop/NetworkManager"))) |
80 .WillOnce(Return(mock_network_manager_proxy_.get())); | 77 .WillOnce(Return(mock_network_manager_proxy_.get())); |
81 // Likewise, set an expectation for mock_device_proxy_. | 78 // Likewise, set an expectation for mock_device_proxy_. |
82 EXPECT_CALL(*mock_bus_, GetObjectProxy( | 79 EXPECT_CALL( |
83 "org.freedesktop.NetworkManager", | 80 *mock_bus_.get(), |
84 dbus::ObjectPath("/org/freedesktop/NetworkManager/Devices/0"))) | 81 GetObjectProxy( |
| 82 "org.freedesktop.NetworkManager", |
| 83 dbus::ObjectPath("/org/freedesktop/NetworkManager/Devices/0"))) |
85 .WillOnce(Return(mock_device_proxy_.get())) | 84 .WillOnce(Return(mock_device_proxy_.get())) |
86 .WillOnce(Return(mock_device_proxy_.get())); | 85 .WillOnce(Return(mock_device_proxy_.get())); |
87 // Likewise, set an expectation for mock_access_point_proxy_. | 86 // Likewise, set an expectation for mock_access_point_proxy_. |
88 EXPECT_CALL(*mock_bus_, GetObjectProxy( | 87 EXPECT_CALL( |
89 "org.freedesktop.NetworkManager", | 88 *mock_bus_.get(), |
90 dbus::ObjectPath("/org/freedesktop/NetworkManager/AccessPoint/0"))) | 89 GetObjectProxy( |
| 90 "org.freedesktop.NetworkManager", |
| 91 dbus::ObjectPath("/org/freedesktop/NetworkManager/AccessPoint/0"))) |
91 .WillOnce(Return(mock_access_point_proxy_.get())); | 92 .WillOnce(Return(mock_access_point_proxy_.get())); |
92 | 93 |
93 // ShutdownAndBlock() should be called. | 94 // ShutdownAndBlock() should be called. |
94 EXPECT_CALL(*mock_bus_, ShutdownAndBlock()).WillOnce(Return()); | 95 EXPECT_CALL(*mock_bus_.get(), ShutdownAndBlock()).WillOnce(Return()); |
95 | 96 |
96 // Create the wlan API with the mock bus object injected. | 97 // Create the wlan API with the mock bus object injected. |
97 wifi_provider_linux_ = new WifiDataProviderLinux; | 98 wifi_provider_linux_ = new WifiDataProviderLinux; |
98 wlan_api_.reset( | 99 wlan_api_.reset( |
99 wifi_provider_linux_->NewWlanApiForTesting(mock_bus_.get())); | 100 wifi_provider_linux_->NewWlanApiForTesting(mock_bus_.get())); |
100 ASSERT_TRUE(wlan_api_.get()); | 101 ASSERT_TRUE(wlan_api_.get()); |
101 } | 102 } |
102 | 103 |
103 protected: | 104 protected: |
104 // DeviceDataProviderImplBase, a super class of WifiDataProviderLinux, | 105 // DeviceDataProviderImplBase, a super class of WifiDataProviderLinux, |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 222 |
222 // Check the contents of the access point data. | 223 // Check the contents of the access point data. |
223 // The expected values come from CreateAccessPointProxyResponse() above. | 224 // The expected values come from CreateAccessPointProxyResponse() above. |
224 EXPECT_EQ("test", UTF16ToUTF8(access_point_data.ssid)); | 225 EXPECT_EQ("test", UTF16ToUTF8(access_point_data.ssid)); |
225 EXPECT_EQ("00-11-22-33-44-55", UTF16ToUTF8(access_point_data.mac_address)); | 226 EXPECT_EQ("00-11-22-33-44-55", UTF16ToUTF8(access_point_data.mac_address)); |
226 EXPECT_EQ(-50, access_point_data.radio_signal_strength); | 227 EXPECT_EQ(-50, access_point_data.radio_signal_strength); |
227 EXPECT_EQ(4, access_point_data.channel); | 228 EXPECT_EQ(4, access_point_data.channel); |
228 } | 229 } |
229 | 230 |
230 } // namespace content | 231 } // namespace content |
OLD | NEW |