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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 const char kPrivetInfoResponse[] = | 62 const char kPrivetInfoResponse[] = |
63 "{" | 63 "{\"version\":\"3.0\"," |
64 "\"x-privet-token\": \"sample\"" | 64 "\"endpoints\":{\"httpsPort\": 443}," |
65 "}"; | 65 "\"authentication\":{" |
66 | 66 " \"mode\":[\"anonymous\",\"pairing\",\"cloud\"]," |
67 const char kPrivetPingResponse[] = | 67 " \"pairing\":[\"embeddedCode\"]," |
68 "{" | 68 " \"crypto\":[\"p224_spake2\"]" |
69 "\"response\": \"pong\"" | 69 "}}"; |
70 "}"; | |
71 | 70 |
72 #if defined(ENABLE_MDNS) | 71 #if defined(ENABLE_MDNS) |
73 | 72 |
74 const uint8 kAnnouncePacket[] = { | 73 const uint8 kAnnouncePacket[] = { |
75 // Header | 74 // Header |
76 0x00, 0x00, // ID is zeroed out | 75 0x00, 0x00, // ID is zeroed out |
77 0x80, 0x00, // Standard query response, no error | 76 0x80, 0x00, // Standard query response, no error |
78 0x00, 0x00, // No questions (for simplicity) | 77 0x00, 0x00, // No questions (for simplicity) |
79 0x00, 0x05, // 5 RR (answers) | 78 0x00, 0x05, // 5 RR (answers) |
80 0x00, 0x00, // 0 authority RRs | 79 0x00, 0x00, // 0 authority RRs |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 GURL("https://www.googleapis.com/clouddevices/v1/devices"), kGCDResponse); | 281 GURL("https://www.googleapis.com/clouddevices/v1/devices"), kGCDResponse); |
283 | 282 |
284 EXPECT_TRUE(RunExtensionSubtest("gcd_private/api", "get_cloud_list.html")); | 283 EXPECT_TRUE(RunExtensionSubtest("gcd_private/api", "get_cloud_list.html")); |
285 } | 284 } |
286 | 285 |
287 IN_PROC_BROWSER_TEST_F(GcdPrivateAPITest, Session) { | 286 IN_PROC_BROWSER_TEST_F(GcdPrivateAPITest, Session) { |
288 url_fetcher_factory_.SetFakeResponse(GURL("http://1.2.3.4:9090/privet/info"), | 287 url_fetcher_factory_.SetFakeResponse(GURL("http://1.2.3.4:9090/privet/info"), |
289 kPrivetInfoResponse, | 288 kPrivetInfoResponse, |
290 net::HTTP_OK, | 289 net::HTTP_OK, |
291 net::URLRequestStatus::SUCCESS); | 290 net::URLRequestStatus::SUCCESS); |
292 | |
293 url_fetcher_factory_.SetFakeResponse(GURL("http://1.2.3.4:9090/privet/ping"), | |
294 kPrivetPingResponse, | |
295 net::HTTP_OK, | |
296 net::URLRequestStatus::SUCCESS); | |
297 | |
298 EXPECT_TRUE(RunExtensionSubtest("gcd_private/api", "session.html")); | 291 EXPECT_TRUE(RunExtensionSubtest("gcd_private/api", "session.html")); |
299 } | 292 } |
300 | 293 |
301 #if defined(ENABLE_MDNS) | 294 #if defined(ENABLE_MDNS) |
302 | 295 |
303 IN_PROC_BROWSER_TEST_F(GcdPrivateAPITest, AddBefore) { | 296 IN_PROC_BROWSER_TEST_F(GcdPrivateAPITest, AddBefore) { |
304 test_service_discovery_client_->SimulateReceive(kAnnouncePacket, | 297 test_service_discovery_client_->SimulateReceive(kAnnouncePacket, |
305 sizeof(kAnnouncePacket)); | 298 sizeof(kAnnouncePacket)); |
306 | 299 |
307 EXPECT_TRUE( | 300 EXPECT_TRUE( |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 EXPECT_CALL(wifi_manager_factory_, WifiManagerCreated()) | 357 EXPECT_CALL(wifi_manager_factory_, WifiManagerCreated()) |
365 .WillOnce(Invoke(this, &GcdPrivateAPITest::OnCreateWifiManager)); | 358 .WillOnce(Invoke(this, &GcdPrivateAPITest::OnCreateWifiManager)); |
366 #endif | 359 #endif |
367 | 360 |
368 EXPECT_TRUE(RunExtensionSubtest("gcd_private/api", "wifi_password.html")); | 361 EXPECT_TRUE(RunExtensionSubtest("gcd_private/api", "wifi_password.html")); |
369 } | 362 } |
370 | 363 |
371 #endif // ENABLE_WIFI_BOOTSTRAPPING | 364 #endif // ENABLE_WIFI_BOOTSTRAPPING |
372 | 365 |
373 } // namespace | 366 } // namespace |
OLD | NEW |