| 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/threading/thread_task_runner_handle.h" | 8 #include "base/threading/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" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 : url_fetcher_factory_( | 83 : url_fetcher_factory_( |
| 84 &url_fetcher_impl_factory_, | 84 &url_fetcher_impl_factory_, |
| 85 base::Bind(&GcdPrivateAPITest::CreateFakeURLFetcher, | 85 base::Bind(&GcdPrivateAPITest::CreateFakeURLFetcher, |
| 86 base::Unretained(this))) {} | 86 base::Unretained(this))) {} |
| 87 | 87 |
| 88 void SetUpCommandLine(base::CommandLine* command_line) override { | 88 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 89 ExtensionApiTest::SetUpCommandLine(command_line); | 89 ExtensionApiTest::SetUpCommandLine(command_line); |
| 90 command_line->AppendSwitchASCII( | 90 command_line->AppendSwitchASCII( |
| 91 extensions::switches::kWhitelistedExtensionID, | 91 extensions::switches::kWhitelistedExtensionID, |
| 92 "ddchlicdkolnonkihahngkmmmjnjlkkf"); | 92 "ddchlicdkolnonkihahngkmmmjnjlkkf"); |
| 93 command_line->AppendSwitch(switches::kDisableDeviceDiscoveryNotifications); |
| 93 } | 94 } |
| 94 | 95 |
| 95 std::unique_ptr<net::FakeURLFetcher> CreateFakeURLFetcher( | 96 std::unique_ptr<net::FakeURLFetcher> CreateFakeURLFetcher( |
| 96 const GURL& url, | 97 const GURL& url, |
| 97 net::URLFetcherDelegate* fetcher_delegate, | 98 net::URLFetcherDelegate* fetcher_delegate, |
| 98 const std::string& response_data, | 99 const std::string& response_data, |
| 99 net::HttpStatusCode response_code, | 100 net::HttpStatusCode response_code, |
| 100 net::URLRequestStatus::Status status) { | 101 net::URLRequestStatus::Status status) { |
| 101 std::unique_ptr<net::FakeURLFetcher> fetcher(new net::FakeURLFetcher( | 102 std::unique_ptr<net::FakeURLFetcher> fetcher(new net::FakeURLFetcher( |
| 102 url, fetcher_delegate, response_data, response_code, status)); | 103 url, fetcher_delegate, response_data, response_code, status)); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 base::Bind( | 136 base::Bind( |
| 136 &local_discovery::TestServiceDiscoveryClient::SimulateReceive, | 137 &local_discovery::TestServiceDiscoveryClient::SimulateReceive, |
| 137 test_service_discovery_client_, packet, size), | 138 test_service_discovery_client_, packet, size), |
| 138 base::TimeDelta::FromSeconds(1)); | 139 base::TimeDelta::FromSeconds(1)); |
| 139 } | 140 } |
| 140 | 141 |
| 141 scoped_refptr<local_discovery::TestServiceDiscoveryClient> | 142 scoped_refptr<local_discovery::TestServiceDiscoveryClient> |
| 142 test_service_discovery_client_; | 143 test_service_discovery_client_; |
| 143 }; | 144 }; |
| 144 | 145 |
| 145 // Flaky on Linux(dbg). https://crbug.com/689305 | 146 IN_PROC_BROWSER_TEST_F(GcdPrivateWithMdnsAPITest, DeviceInfo) { |
| 146 IN_PROC_BROWSER_TEST_F(GcdPrivateWithMdnsAPITest, DISABLED_DeviceInfo) { | |
| 147 test_service_discovery_client_->SimulateReceive(kAnnouncePacket, | 147 test_service_discovery_client_->SimulateReceive(kAnnouncePacket, |
| 148 sizeof(kAnnouncePacket)); | 148 sizeof(kAnnouncePacket)); |
| 149 url_fetcher_factory_.SetFakeResponse(GURL("http://1.2.3.4:8888/privet/info"), | 149 url_fetcher_factory_.SetFakeResponse(GURL("http://1.2.3.4:8888/privet/info"), |
| 150 kPrivetInfoResponse, | 150 kPrivetInfoResponse, |
| 151 net::HTTP_OK, | 151 net::HTTP_OK, |
| 152 net::URLRequestStatus::SUCCESS); | 152 net::URLRequestStatus::SUCCESS); |
| 153 EXPECT_TRUE(RunExtensionSubtest("gcd_private/api", "device_info.html")); | 153 EXPECT_TRUE(RunExtensionSubtest("gcd_private/api", "device_info.html")); |
| 154 } | 154 } |
| 155 | 155 |
| 156 IN_PROC_BROWSER_TEST_F(GcdPrivateWithMdnsAPITest, Session) { | 156 IN_PROC_BROWSER_TEST_F(GcdPrivateWithMdnsAPITest, Session) { |
| 157 test_service_discovery_client_->SimulateReceive(kAnnouncePacket, | 157 test_service_discovery_client_->SimulateReceive(kAnnouncePacket, |
| 158 sizeof(kAnnouncePacket)); | 158 sizeof(kAnnouncePacket)); |
| 159 url_fetcher_factory_.SetFakeResponse(GURL("http://1.2.3.4:8888/privet/info"), | 159 url_fetcher_factory_.SetFakeResponse(GURL("http://1.2.3.4:8888/privet/info"), |
| 160 kPrivetInfoResponse, | 160 kPrivetInfoResponse, |
| 161 net::HTTP_OK, | 161 net::HTTP_OK, |
| 162 net::URLRequestStatus::SUCCESS); | 162 net::URLRequestStatus::SUCCESS); |
| 163 EXPECT_TRUE(RunExtensionSubtest("gcd_private/api", "session.html")); | 163 EXPECT_TRUE(RunExtensionSubtest("gcd_private/api", "session.html")); |
| 164 } | 164 } |
| 165 | 165 |
| 166 } // namespace | 166 } // namespace |
| OLD | NEW |