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/thread_task_runner_handle.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" |
11 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
12 #include "chrome/browser/local_discovery/gcd_api_flow.h" | 12 #include "chrome/browser/local_discovery/gcd_api_flow.h" |
13 #include "chrome/browser/local_discovery/wifi/mock_wifi_manager.h" | 13 #include "chrome/browser/local_discovery/wifi/mock_wifi_manager.h" |
14 #include "chrome/common/extensions/api/mdns.h" | 14 #include "chrome/common/extensions/api/mdns.h" |
15 #include "extensions/common/switches.h" | 15 #include "extensions/common/switches.h" |
16 #include "net/url_request/test_url_fetcher_factory.h" | 16 #include "net/url_request/test_url_fetcher_factory.h" |
17 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
18 | 18 |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 | 296 |
297 IN_PROC_BROWSER_TEST_F(GcdPrivateAPITest, AddBefore) { | 297 IN_PROC_BROWSER_TEST_F(GcdPrivateAPITest, AddBefore) { |
298 test_service_discovery_client_->SimulateReceive(kAnnouncePacket, | 298 test_service_discovery_client_->SimulateReceive(kAnnouncePacket, |
299 sizeof(kAnnouncePacket)); | 299 sizeof(kAnnouncePacket)); |
300 | 300 |
301 EXPECT_TRUE( | 301 EXPECT_TRUE( |
302 RunExtensionSubtest("gcd_private/api", "receive_new_device.html")); | 302 RunExtensionSubtest("gcd_private/api", "receive_new_device.html")); |
303 } | 303 } |
304 | 304 |
305 IN_PROC_BROWSER_TEST_F(GcdPrivateAPITest, AddAfter) { | 305 IN_PROC_BROWSER_TEST_F(GcdPrivateAPITest, AddAfter) { |
306 base::MessageLoopProxy::current()->PostDelayedTask( | 306 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
307 FROM_HERE, | 307 FROM_HERE, |
308 base::Bind(&local_discovery::TestServiceDiscoveryClient::SimulateReceive, | 308 base::Bind(&local_discovery::TestServiceDiscoveryClient::SimulateReceive, |
309 test_service_discovery_client_, | 309 test_service_discovery_client_, |
310 kAnnouncePacket, | 310 kAnnouncePacket, |
311 sizeof(kAnnouncePacket)), | 311 sizeof(kAnnouncePacket)), |
312 base::TimeDelta::FromSeconds(1)); | 312 base::TimeDelta::FromSeconds(1)); |
313 | 313 |
314 EXPECT_TRUE( | 314 EXPECT_TRUE( |
315 RunExtensionSubtest("gcd_private/api", "receive_new_device.html")); | 315 RunExtensionSubtest("gcd_private/api", "receive_new_device.html")); |
316 } | 316 } |
317 | 317 |
318 IN_PROC_BROWSER_TEST_F(GcdPrivateAPITest, AddRemove) { | 318 IN_PROC_BROWSER_TEST_F(GcdPrivateAPITest, AddRemove) { |
319 test_service_discovery_client_->SimulateReceive(kAnnouncePacket, | 319 test_service_discovery_client_->SimulateReceive(kAnnouncePacket, |
320 sizeof(kAnnouncePacket)); | 320 sizeof(kAnnouncePacket)); |
321 | 321 |
322 base::MessageLoopProxy::current()->PostDelayedTask( | 322 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
323 FROM_HERE, | 323 FROM_HERE, |
324 base::Bind(&local_discovery::TestServiceDiscoveryClient::SimulateReceive, | 324 base::Bind(&local_discovery::TestServiceDiscoveryClient::SimulateReceive, |
325 test_service_discovery_client_, | 325 test_service_discovery_client_, |
326 kGoodbyePacket, | 326 kGoodbyePacket, |
327 sizeof(kGoodbyePacket)), | 327 sizeof(kGoodbyePacket)), |
328 base::TimeDelta::FromSeconds(1)); | 328 base::TimeDelta::FromSeconds(1)); |
329 | 329 |
330 EXPECT_TRUE(RunExtensionSubtest("gcd_private/api", "remove_device.html")); | 330 EXPECT_TRUE(RunExtensionSubtest("gcd_private/api", "remove_device.html")); |
331 } | 331 } |
332 | 332 |
(...skipping 25 matching lines...) Expand all Loading... |
358 EXPECT_CALL(wifi_manager_factory_, WifiManagerCreated()) | 358 EXPECT_CALL(wifi_manager_factory_, WifiManagerCreated()) |
359 .WillOnce(Invoke(this, &GcdPrivateAPITest::OnCreateWifiManager)); | 359 .WillOnce(Invoke(this, &GcdPrivateAPITest::OnCreateWifiManager)); |
360 #endif | 360 #endif |
361 | 361 |
362 EXPECT_TRUE(RunExtensionSubtest("gcd_private/api", "wifi_password.html")); | 362 EXPECT_TRUE(RunExtensionSubtest("gcd_private/api", "wifi_password.html")); |
363 } | 363 } |
364 | 364 |
365 #endif // ENABLE_WIFI_BOOTSTRAPPING | 365 #endif // ENABLE_WIFI_BOOTSTRAPPING |
366 | 366 |
367 } // namespace | 367 } // namespace |
OLD | NEW |