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 "base/timer/mock_timer.h" | 8 #include "base/timer/mock_timer.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "chrome/browser/extensions/extension_apitest.h" | 10 #include "chrome/browser/extensions/extension_apitest.h" |
11 #include "chrome/browser/extensions/extension_function_test_utils.h" | 11 #include "chrome/browser/extensions/extension_function_test_utils.h" |
12 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
15 #include "extensions/browser/api/cast_channel/cast_channel_api.h" | 15 #include "extensions/browser/api/cast_channel/cast_channel_api.h" |
16 #include "extensions/browser/api/cast_channel/cast_socket.h" | 16 #include "extensions/browser/api/cast_channel/cast_socket.h" |
17 #include "extensions/browser/api/cast_channel/cast_test_util.h" | 17 #include "extensions/browser/api/cast_channel/cast_test_util.h" |
18 #include "extensions/browser/api/cast_channel/logger.h" | 18 #include "extensions/browser/api/cast_channel/logger.h" |
19 #include "extensions/common/api/cast_channel.h" | 19 #include "extensions/common/api/cast_channel.h" |
20 #include "extensions/common/api/cast_channel/cast_channel.pb.h" | 20 #include "extensions/common/api/cast_channel/cast_channel.pb.h" |
21 #include "extensions/common/switches.h" | 21 #include "extensions/common/switches.h" |
22 #include "extensions/common/test_util.h" | 22 #include "extensions/common/test_util.h" |
23 #include "extensions/test/extension_test_message_listener.h" | 23 #include "extensions/test/extension_test_message_listener.h" |
24 #include "extensions/test/result_catcher.h" | 24 #include "extensions/test/result_catcher.h" |
25 #include "net/base/completion_callback.h" | 25 #include "net/base/completion_callback.h" |
| 26 #include "net/base/ip_address.h" |
26 #include "net/base/net_errors.h" | 27 #include "net/base/net_errors.h" |
27 #include "net/log/test_net_log.h" | 28 #include "net/log/test_net_log.h" |
28 #include "testing/gmock/include/gmock/gmock.h" | 29 #include "testing/gmock/include/gmock/gmock.h" |
29 #include "testing/gmock_mutant.h" | 30 #include "testing/gmock_mutant.h" |
30 | 31 |
31 // TODO(mfoltz): Mock out the ApiResourceManager to resolve threading issues | 32 // TODO(mfoltz): Mock out the ApiResourceManager to resolve threading issues |
32 // (crbug.com/398242) and simulate unloading of the extension. | 33 // (crbug.com/398242) and simulate unloading of the extension. |
33 | 34 |
34 namespace cast_channel = extensions::api::cast_channel; | 35 namespace cast_channel = extensions::api::cast_channel; |
35 using cast_channel::CastMessage; | 36 using cast_channel::CastMessage; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 command_line->AppendSwitchASCII( | 89 command_line->AppendSwitchASCII( |
89 extensions::switches::kWhitelistedExtensionID, | 90 extensions::switches::kWhitelistedExtensionID, |
90 cast_channel::kTestExtensionId); | 91 cast_channel::kTestExtensionId); |
91 } | 92 } |
92 | 93 |
93 void SetUpMockCastSocket() { | 94 void SetUpMockCastSocket() { |
94 extensions::CastChannelAPI* api = GetApi(); | 95 extensions::CastChannelAPI* api = GetApi(); |
95 timeout_timer_ = new base::MockTimer(true, false); | 96 timeout_timer_ = new base::MockTimer(true, false); |
96 api->SetPingTimeoutTimerForTest(make_scoped_ptr(timeout_timer_)); | 97 api->SetPingTimeoutTimerForTest(make_scoped_ptr(timeout_timer_)); |
97 | 98 |
98 net::IPAddressNumber ip_number; | 99 net::IPEndPoint ip_endpoint(net::IPAddress(192, 168, 1, 1), 8009); |
99 net::ParseIPLiteralToNumber("192.168.1.1", &ip_number); | |
100 net::IPEndPoint ip_endpoint(ip_number, 8009); | |
101 mock_cast_socket_ = new MockCastSocket; | 100 mock_cast_socket_ = new MockCastSocket; |
102 // Transfers ownership of the socket. | 101 // Transfers ownership of the socket. |
103 api->SetSocketForTest(make_scoped_ptr<CastSocket>(mock_cast_socket_)); | 102 api->SetSocketForTest(make_scoped_ptr<CastSocket>(mock_cast_socket_)); |
104 ON_CALL(*mock_cast_socket_, set_id(_)) | 103 ON_CALL(*mock_cast_socket_, set_id(_)) |
105 .WillByDefault(SaveArg<0>(&channel_id_)); | 104 .WillByDefault(SaveArg<0>(&channel_id_)); |
106 ON_CALL(*mock_cast_socket_, id()) | 105 ON_CALL(*mock_cast_socket_, id()) |
107 .WillByDefault(ReturnPointee(&channel_id_)); | 106 .WillByDefault(ReturnPointee(&channel_id_)); |
108 ON_CALL(*mock_cast_socket_, ip_endpoint()) | 107 ON_CALL(*mock_cast_socket_, ip_endpoint()) |
109 .WillByDefault(ReturnRef(ip_endpoint_)); | 108 .WillByDefault(ReturnRef(ip_endpoint_)); |
110 ON_CALL(*mock_cast_socket_, channel_auth()) | 109 ON_CALL(*mock_cast_socket_, channel_auth()) |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 #define MAYBE_TestSetAuthorityKeys DISABLED_TestSetAuthorityKeys | 570 #define MAYBE_TestSetAuthorityKeys DISABLED_TestSetAuthorityKeys |
572 #else | 571 #else |
573 #define MAYBE_TestSetAuthorityKeys TestSetAuthorityKeys | 572 #define MAYBE_TestSetAuthorityKeys TestSetAuthorityKeys |
574 #endif | 573 #endif |
575 // Test loading extension, opening a channel with ConnectInfo, adding a | 574 // Test loading extension, opening a channel with ConnectInfo, adding a |
576 // listener, writing, reading, and closing. | 575 // listener, writing, reading, and closing. |
577 IN_PROC_BROWSER_TEST_F(CastChannelAPITest, MAYBE_TestSetAuthorityKeys) { | 576 IN_PROC_BROWSER_TEST_F(CastChannelAPITest, MAYBE_TestSetAuthorityKeys) { |
578 EXPECT_TRUE( | 577 EXPECT_TRUE( |
579 RunExtensionSubtest("cast_channel/api", "test_authority_keys.html")); | 578 RunExtensionSubtest("cast_channel/api", "test_authority_keys.html")); |
580 } | 579 } |
OLD | NEW |