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

Side by Side Diff: chrome/browser/extensions/api/gcd_private/gcd_private_apitest.cc

Issue 387453002: Re-submit of https://codereview.chromium.org/356613002 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Thu 07/10/2014 2:23:32.16 Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/bind.h" 5 #include "base/bind.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/message_loop/message_loop_proxy.h" 8 #include "base/message_loop/message_loop_proxy.h"
9 #include "chrome/browser/extensions/api/gcd_private/gcd_private_api.h" 9 #include "chrome/browser/extensions/api/gcd_private/gcd_private_api.h"
10 #include "chrome/browser/extensions/extension_apitest.h" 10 #include "chrome/browser/extensions/extension_apitest.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 0x09, 'm', 'y', 'S', 'e', 'r', 'v', 'i', 'c', 'e', 0xc0, 0x0c, 123 0x09, 'm', 'y', 'S', 'e', 'r', 'v', 'i', 'c', 'e', 0xc0, 0x0c,
124 0x00, 0x21, // Type is SRV 124 0x00, 0x21, // Type is SRV
125 0x00, 0x01, // CLASS is IN 125 0x00, 0x01, // CLASS is IN
126 0x00, 0x00, // TTL (4 bytes) is 0 seconds. 126 0x00, 0x00, // TTL (4 bytes) is 0 seconds.
127 0x00, 0x00, 0x00, 0x17, // RDLENGTH is 23 127 0x00, 0x00, 0x00, 0x17, // RDLENGTH is 23
128 0x00, 0x00, 0x00, 0x00, 0x22, 0xb8, // port 8888 128 0x00, 0x00, 0x00, 0x00, 0x22, 0xb8, // port 8888
129 0x09, 'm', 'y', 'S', 'e', 'r', 'v', 'i', 'c', 'e', 0x05, 'l', 129 0x09, 'm', 'y', 'S', 'e', 'r', 'v', 'i', 'c', 'e', 0x05, 'l',
130 'o', 'c', 'a', 'l', 0x00, 130 'o', 'c', 'a', 'l', 0x00,
131 }; 131 };
132 132
133 const uint8 kQueryPacket[] = {
134 // Header
135 0x00, 0x00, // ID is zeroed out
136 0x00, 0x00, // No flags.
137 0x00, 0x01, // One question.
138 0x00, 0x00, // 0 RRs (answers)
139 0x00, 0x00, // 0 authority RRs
140 0x00, 0x00, // 0 additional RRs
141
142 // Question
143 // This part is echoed back from the respective query.
144 0x07, '_', 'p', 'r', 'i', 'v', 'e', 't', 0x04, '_', 't', 'c',
145 'p', 0x05, 'l', 'o', 'c', 'a', 'l', 0x00, 0x00, 0x0c, // TYPE is PTR.
146 0x00, 0x01, // CLASS is IN.
147 };
148
133 #endif // ENABLE_MDNS 149 #endif // ENABLE_MDNS
134 150
135 // Sentinel value to signify the request should fail. 151 // Sentinel value to signify the request should fail.
136 const char kResponseValueFailure[] = "FAILURE"; 152 const char kResponseValueFailure[] = "FAILURE";
137 153
138 class FakeGCDApiFlowFactory 154 class FakeGCDApiFlowFactory
139 : public extensions::GcdPrivateAPI::GCDApiFlowFactoryForTests { 155 : public extensions::GcdPrivateAPI::GCDApiFlowFactoryForTests {
140 public: 156 public:
141 FakeGCDApiFlowFactory() { 157 FakeGCDApiFlowFactory() {
142 extensions::GcdPrivateAPI::SetGCDApiFlowFactoryForTests(this); 158 extensions::GcdPrivateAPI::SetGCDApiFlowFactoryForTests(this);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 FROM_HERE, 263 FROM_HERE,
248 base::Bind(&local_discovery::TestServiceDiscoveryClient::SimulateReceive, 264 base::Bind(&local_discovery::TestServiceDiscoveryClient::SimulateReceive,
249 test_service_discovery_client_, 265 test_service_discovery_client_,
250 kGoodbyePacket, 266 kGoodbyePacket,
251 sizeof(kGoodbyePacket)), 267 sizeof(kGoodbyePacket)),
252 base::TimeDelta::FromSeconds(1)); 268 base::TimeDelta::FromSeconds(1));
253 269
254 EXPECT_TRUE(RunExtensionSubtest("gcd_private/api", "remove_device.html")); 270 EXPECT_TRUE(RunExtensionSubtest("gcd_private/api", "remove_device.html"));
255 } 271 }
256 272
273 IN_PROC_BROWSER_TEST_F(GcdPrivateAPITest, SendQuery) {
274 // TODO(noamsml): Win Dbg has a workaround that makes RunExtensionSubtest
275 // always return true without actually running the test. Remove when fixed.
276 // See http://crbug.com/177163 for details.
277 #if !defined(OS_WIN) || defined(NDEBUG)
278 EXPECT_CALL(*test_service_discovery_client_,
279 OnSendTo(std::string(reinterpret_cast<const char*>(kQueryPacket),
280 sizeof(kQueryPacket)))).Times(2);
281 #endif
282 EXPECT_TRUE(RunExtensionSubtest("gcd_private/api", "send_query.html"));
283 }
284
257 #endif // ENABLE_MDNS 285 #endif // ENABLE_MDNS
258 286
259 } // namespace 287 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698