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/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
9 #include "chrome/browser/extensions/extension_function_test_utils.h" | 9 #include "chrome/browser/extensions/extension_function_test_utils.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
13 #include "extensions/browser/api/cast_channel/cast_channel_api.h" | 13 #include "extensions/browser/api/cast_channel/cast_channel_api.h" |
14 #include "extensions/browser/api/cast_channel/cast_socket.h" | 14 #include "extensions/browser/api/cast_channel/cast_socket.h" |
15 #include "extensions/browser/api/cast_channel/logger.h" | 15 #include "extensions/browser/api/cast_channel/logger.h" |
16 #include "extensions/common/api/cast_channel.h" | 16 #include "extensions/common/api/cast_channel.h" |
17 #include "extensions/common/switches.h" | 17 #include "extensions/common/switches.h" |
| 18 #include "extensions/test/result_catcher.h" |
18 #include "net/base/capturing_net_log.h" | 19 #include "net/base/capturing_net_log.h" |
19 #include "net/base/completion_callback.h" | 20 #include "net/base/completion_callback.h" |
20 #include "net/base/net_errors.h" | 21 #include "net/base/net_errors.h" |
21 #include "testing/gmock/include/gmock/gmock.h" | 22 #include "testing/gmock/include/gmock/gmock.h" |
22 #include "testing/gmock_mutant.h" | 23 #include "testing/gmock_mutant.h" |
23 | 24 |
24 // TODO(mfoltz): Mock out the ApiResourceManager to resolve threading issues | 25 // TODO(mfoltz): Mock out the ApiResourceManager to resolve threading issues |
25 // (crbug.com/398242) and simulate unloading of the extension. | 26 // (crbug.com/398242) and simulate unloading of the extension. |
26 | 27 |
27 namespace cast_channel = extensions::core_api::cast_channel; | 28 namespace cast_channel = extensions::core_api::cast_channel; |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 .WillRepeatedly(Return(cast_channel::READY_STATE_OPEN)); | 241 .WillRepeatedly(Return(cast_channel::READY_STATE_OPEN)); |
241 EXPECT_CALL(*mock_cast_socket_, Close(_)) | 242 EXPECT_CALL(*mock_cast_socket_, Close(_)) |
242 .WillOnce(InvokeCompletionCallback<0>(net::OK)); | 243 .WillOnce(InvokeCompletionCallback<0>(net::OK)); |
243 EXPECT_CALL(*mock_cast_socket_, ready_state()) | 244 EXPECT_CALL(*mock_cast_socket_, ready_state()) |
244 .WillOnce(Return(cast_channel::READY_STATE_CLOSED)); | 245 .WillOnce(Return(cast_channel::READY_STATE_CLOSED)); |
245 } | 246 } |
246 | 247 |
247 EXPECT_TRUE(RunExtensionSubtest("cast_channel/api", | 248 EXPECT_TRUE(RunExtensionSubtest("cast_channel/api", |
248 "test_open_receive_close.html")); | 249 "test_open_receive_close.html")); |
249 | 250 |
250 ResultCatcher catcher; | 251 extensions::ResultCatcher catcher; |
251 CallOnMessage("some-message"); | 252 CallOnMessage("some-message"); |
252 CallOnMessage("some-message"); | 253 CallOnMessage("some-message"); |
253 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 254 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
254 } | 255 } |
255 | 256 |
256 // TODO(imcheng): Win Dbg has a workaround that makes RunExtensionSubtest | 257 // TODO(imcheng): Win Dbg has a workaround that makes RunExtensionSubtest |
257 // always return true without actually running the test. Remove when fixed. | 258 // always return true without actually running the test. Remove when fixed. |
258 #if defined(OS_WIN) && !defined(NDEBUG) | 259 #if defined(OS_WIN) && !defined(NDEBUG) |
259 #define MAYBE_TestGetLogs DISABLED_TestGetLogs | 260 #define MAYBE_TestGetLogs DISABLED_TestGetLogs |
260 #else | 261 #else |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 cast_channel_send_function.get(), | 386 cast_channel_send_function.get(), |
386 "[{\"channelId\": 1, \"url\": \"cast://127.0.0.1:8009\", " | 387 "[{\"channelId\": 1, \"url\": \"cast://127.0.0.1:8009\", " |
387 "\"connectInfo\": " | 388 "\"connectInfo\": " |
388 "{\"ipAddress\": \"127.0.0.1\", \"port\": 8009, " | 389 "{\"ipAddress\": \"127.0.0.1\", \"port\": 8009, " |
389 "\"auth\": \"ssl\"}, \"readyState\": \"open\"}, " | 390 "\"auth\": \"ssl\"}, \"readyState\": \"open\"}, " |
390 "{\"namespace_\": \"foo\", \"sourceId\": \"src\", " | 391 "{\"namespace_\": \"foo\", \"sourceId\": \"src\", " |
391 "\"destinationId\": \"\", \"data\": \"data\"}]", | 392 "\"destinationId\": \"\", \"data\": \"data\"}]", |
392 browser()); | 393 browser()); |
393 EXPECT_EQ(error, "message_info.destination_id is required"); | 394 EXPECT_EQ(error, "message_info.destination_id is required"); |
394 } | 395 } |
OLD | NEW |