OLD | NEW |
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 " \"connectionStatus\": \"offline\"" | 52 " \"connectionStatus\": \"offline\"" |
53 " }" | 53 " }" |
54 " }," | 54 " }," |
55 " \"channel\": {" | 55 " \"channel\": {" |
56 " \"supportedType\": \"xmpp\"" | 56 " \"supportedType\": \"xmpp\"" |
57 " }," | 57 " }," |
58 " \"personalizedInfo\": {" | 58 " \"personalizedInfo\": {" |
59 " \"maxRole\": \"owner\"" | 59 " \"maxRole\": \"owner\"" |
60 " }}]}"; | 60 " }}]}"; |
61 | 61 |
| 62 #if defined(ENABLE_MDNS) |
| 63 |
62 const char kPrivetInfoResponse[] = | 64 const char kPrivetInfoResponse[] = |
63 "{\"version\":\"3.0\"," | 65 "{\"version\":\"3.0\"," |
64 "\"endpoints\":{\"httpsPort\": 443}," | 66 "\"endpoints\":{\"httpsPort\": 443}," |
65 "\"authentication\":{" | 67 "\"authentication\":{" |
66 " \"mode\":[\"anonymous\",\"pairing\",\"cloud\"]," | 68 " \"mode\":[\"anonymous\",\"pairing\",\"cloud\"]," |
67 " \"pairing\":[\"embeddedCode\"]," | 69 " \"pairing\":[\"embeddedCode\"]," |
68 " \"crypto\":[\"p224_spake2\"]" | 70 " \"crypto\":[\"p224_spake2\"]" |
69 "}}"; | 71 "}}"; |
70 | 72 |
71 #if defined(ENABLE_MDNS) | |
72 | |
73 const uint8 kAnnouncePacket[] = { | 73 const uint8 kAnnouncePacket[] = { |
74 // Header | 74 // Header |
75 0x00, 0x00, // ID is zeroed out | 75 0x00, 0x00, // ID is zeroed out |
76 0x80, 0x00, // Standard query response, no error | 76 0x80, 0x00, // Standard query response, no error |
77 0x00, 0x00, // No questions (for simplicity) | 77 0x00, 0x00, // No questions (for simplicity) |
78 0x00, 0x05, // 5 RR (answers) | 78 0x00, 0x05, // 5 RR (answers) |
79 0x00, 0x00, // 0 authority RRs | 79 0x00, 0x00, // 0 authority RRs |
80 0x00, 0x00, // 0 additional RRs | 80 0x00, 0x00, // 0 additional RRs |
81 0x07, '_', 'p', 'r', 'i', 'v', 'e', 't', 0x04, '_', | 81 0x07, '_', 'p', 'r', 'i', 'v', 'e', 't', 0x04, '_', |
82 't', 'c', 'p', 0x05, 'l', 'o', 'c', 'a', 'l', 0x00, | 82 't', 'c', 'p', 0x05, 'l', 'o', 'c', 'a', 'l', 0x00, |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 IN_PROC_BROWSER_TEST_F(GcdPrivateAPITest, GetCloudList) { | 276 IN_PROC_BROWSER_TEST_F(GcdPrivateAPITest, GetCloudList) { |
277 api_flow_factory_.SetResponse( | 277 api_flow_factory_.SetResponse( |
278 GURL("https://www.google.com/cloudprint/search"), kCloudPrintResponse); | 278 GURL("https://www.google.com/cloudprint/search"), kCloudPrintResponse); |
279 | 279 |
280 api_flow_factory_.SetResponse( | 280 api_flow_factory_.SetResponse( |
281 GURL("https://www.googleapis.com/clouddevices/v1/devices"), kGCDResponse); | 281 GURL("https://www.googleapis.com/clouddevices/v1/devices"), kGCDResponse); |
282 | 282 |
283 EXPECT_TRUE(RunExtensionSubtest("gcd_private/api", "get_cloud_list.html")); | 283 EXPECT_TRUE(RunExtensionSubtest("gcd_private/api", "get_cloud_list.html")); |
284 } | 284 } |
285 | 285 |
| 286 #if defined(ENABLE_MDNS) |
286 IN_PROC_BROWSER_TEST_F(GcdPrivateAPITest, Session) { | 287 IN_PROC_BROWSER_TEST_F(GcdPrivateAPITest, Session) { |
287 url_fetcher_factory_.SetFakeResponse(GURL("http://1.2.3.4:9090/privet/info"), | 288 test_service_discovery_client_->SimulateReceive(kAnnouncePacket, |
| 289 sizeof(kAnnouncePacket)); |
| 290 url_fetcher_factory_.SetFakeResponse(GURL("http://1.2.3.4:8888/privet/info"), |
288 kPrivetInfoResponse, | 291 kPrivetInfoResponse, |
289 net::HTTP_OK, | 292 net::HTTP_OK, |
290 net::URLRequestStatus::SUCCESS); | 293 net::URLRequestStatus::SUCCESS); |
291 EXPECT_TRUE(RunExtensionSubtest("gcd_private/api", "session.html")); | 294 EXPECT_TRUE(RunExtensionSubtest("gcd_private/api", "session.html")); |
292 } | 295 } |
293 | 296 |
294 #if defined(ENABLE_MDNS) | |
295 | |
296 IN_PROC_BROWSER_TEST_F(GcdPrivateAPITest, AddBefore) { | 297 IN_PROC_BROWSER_TEST_F(GcdPrivateAPITest, AddBefore) { |
297 test_service_discovery_client_->SimulateReceive(kAnnouncePacket, | 298 test_service_discovery_client_->SimulateReceive(kAnnouncePacket, |
298 sizeof(kAnnouncePacket)); | 299 sizeof(kAnnouncePacket)); |
299 | 300 |
300 EXPECT_TRUE( | 301 EXPECT_TRUE( |
301 RunExtensionSubtest("gcd_private/api", "receive_new_device.html")); | 302 RunExtensionSubtest("gcd_private/api", "receive_new_device.html")); |
302 } | 303 } |
303 | 304 |
304 IN_PROC_BROWSER_TEST_F(GcdPrivateAPITest, AddAfter) { | 305 IN_PROC_BROWSER_TEST_F(GcdPrivateAPITest, AddAfter) { |
305 base::MessageLoopProxy::current()->PostDelayedTask( | 306 base::MessageLoopProxy::current()->PostDelayedTask( |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 EXPECT_CALL(wifi_manager_factory_, WifiManagerCreated()) | 358 EXPECT_CALL(wifi_manager_factory_, WifiManagerCreated()) |
358 .WillOnce(Invoke(this, &GcdPrivateAPITest::OnCreateWifiManager)); | 359 .WillOnce(Invoke(this, &GcdPrivateAPITest::OnCreateWifiManager)); |
359 #endif | 360 #endif |
360 | 361 |
361 EXPECT_TRUE(RunExtensionSubtest("gcd_private/api", "wifi_password.html")); | 362 EXPECT_TRUE(RunExtensionSubtest("gcd_private/api", "wifi_password.html")); |
362 } | 363 } |
363 | 364 |
364 #endif // ENABLE_WIFI_BOOTSTRAPPING | 365 #endif // ENABLE_WIFI_BOOTSTRAPPING |
365 | 366 |
366 } // namespace | 367 } // namespace |
OLD | NEW |