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