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

Side by Side Diff: content/browser/geolocation/wifi_data_provider_linux_unittest.cc

Issue 9378039: dbus: add ObjectPath type (Closed) Base URL: http://git.chromium.org/git/chromium/src@master
Patch Set: added inequality operator Created 8 years, 10 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) 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 "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"
11 #include "dbus/message.h" 11 #include "dbus/message.h"
12 #include "dbus/mock_bus.h" 12 #include "dbus/mock_bus.h"
13 #include "dbus/mock_object_proxy.h" 13 #include "dbus/mock_object_proxy.h"
14 #include "dbus/object_path.h"
14 #include "dbus/object_proxy.h" 15 #include "dbus/object_proxy.h"
15 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 18
18 using ::testing::_; 19 using ::testing::_;
19 using ::testing::Invoke; 20 using ::testing::Invoke;
20 using ::testing::Return; 21 using ::testing::Return;
21 using ::testing::Unused; 22 using ::testing::Unused;
22 23
23 class GeolocationWifiDataProviderLinuxTest : public testing::Test { 24 class GeolocationWifiDataProviderLinuxTest : public testing::Test {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 scoped_ptr<WifiDataProviderCommon::WlanApiInterface> wlan_api_; 109 scoped_ptr<WifiDataProviderCommon::WlanApiInterface> wlan_api_;
109 110
110 private: 111 private:
111 // Creates a response for |mock_network_manager_proxy_|. 112 // Creates a response for |mock_network_manager_proxy_|.
112 dbus::Response* CreateNetowrkManagerProxyResponse( 113 dbus::Response* CreateNetowrkManagerProxyResponse(
113 dbus::MethodCall* method_call, 114 dbus::MethodCall* method_call,
114 Unused) { 115 Unused) {
115 if (method_call->GetInterface() == "org.freedesktop.NetworkManager" && 116 if (method_call->GetInterface() == "org.freedesktop.NetworkManager" &&
116 method_call->GetMember() == "GetDevices") { 117 method_call->GetMember() == "GetDevices") {
117 // The list of devices is asked. Return the object path. 118 // The list of devices is asked. Return the object path.
118 std::vector<std::string> object_paths; 119 std::vector<dbus::ObjectPath> object_paths;
119 object_paths.push_back("/org/freedesktop/NetworkManager/Devices/0"); 120 object_paths.push_back("/org/freedesktop/NetworkManager/Devices/0");
120 121
121 dbus::Response* response = dbus::Response::CreateEmpty(); 122 dbus::Response* response = dbus::Response::CreateEmpty();
122 dbus::MessageWriter writer(response); 123 dbus::MessageWriter writer(response);
123 writer.AppendArrayOfObjectPaths(object_paths); 124 writer.AppendArrayOfObjectPaths(object_paths);
124 return response; 125 return response;
125 } 126 }
126 127
127 LOG(ERROR) << "Unexpected method call: " << method_call->ToString(); 128 LOG(ERROR) << "Unexpected method call: " << method_call->ToString();
128 return NULL; 129 return NULL;
(...skipping 16 matching lines...) Expand all
145 const int kDeviceTypeWifi = 2; 146 const int kDeviceTypeWifi = 2;
146 writer.AppendVariantOfUint32(kDeviceTypeWifi); 147 writer.AppendVariantOfUint32(kDeviceTypeWifi);
147 return response; 148 return response;
148 } 149 }
149 } else if (method_call->GetInterface() == 150 } else if (method_call->GetInterface() ==
150 "org.freedesktop.NetworkManager.Device.Wireless" && 151 "org.freedesktop.NetworkManager.Device.Wireless" &&
151 method_call->GetMember() == "GetAccessPoints") { 152 method_call->GetMember() == "GetAccessPoints") {
152 // The list of access points is asked. Return the object path. 153 // The list of access points is asked. Return the object path.
153 dbus::Response* response = dbus::Response::CreateEmpty(); 154 dbus::Response* response = dbus::Response::CreateEmpty();
154 dbus::MessageWriter writer(response); 155 dbus::MessageWriter writer(response);
155 std::vector<std::string> object_paths; 156 std::vector<dbus::ObjectPath> object_paths;
156 object_paths.push_back("/org/freedesktop/NetworkManager/AccessPoint/0"); 157 object_paths.push_back("/org/freedesktop/NetworkManager/AccessPoint/0");
157 writer.AppendArrayOfObjectPaths(object_paths); 158 writer.AppendArrayOfObjectPaths(object_paths);
158 return response; 159 return response;
159 } 160 }
160 161
161 LOG(ERROR) << "Unexpected method call: " << method_call->ToString(); 162 LOG(ERROR) << "Unexpected method call: " << method_call->ToString();
162 return NULL; 163 return NULL;
163 } 164 }
164 165
165 166
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 ASSERT_EQ(1U, access_point_data_set.size()); 213 ASSERT_EQ(1U, access_point_data_set.size());
213 AccessPointData access_point_data = *access_point_data_set.begin(); 214 AccessPointData access_point_data = *access_point_data_set.begin();
214 215
215 // Check the contents of the access point data. 216 // Check the contents of the access point data.
216 // The expected values come from CreateAccessPointProxyResponse() above. 217 // The expected values come from CreateAccessPointProxyResponse() above.
217 EXPECT_EQ("test", UTF16ToUTF8(access_point_data.ssid)); 218 EXPECT_EQ("test", UTF16ToUTF8(access_point_data.ssid));
218 EXPECT_EQ("00-11-22-33-44-55", UTF16ToUTF8(access_point_data.mac_address)); 219 EXPECT_EQ("00-11-22-33-44-55", UTF16ToUTF8(access_point_data.mac_address));
219 EXPECT_EQ(-50, access_point_data.radio_signal_strength); 220 EXPECT_EQ(-50, access_point_data.radio_signal_strength);
220 EXPECT_EQ(4, access_point_data.channel); 221 EXPECT_EQ(4, access_point_data.channel);
221 } 222 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698