| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/api/cast_channel/cast_channel_api.h" | 8 #include "chrome/browser/extensions/api/cast_channel/cast_channel_api.h" |
| 9 #include "chrome/browser/extensions/api/cast_channel/cast_socket.h" | 9 #include "chrome/browser/extensions/api/cast_channel/cast_socket.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/common/chrome_switches.h" | |
| 13 #include "chrome/common/extensions/api/cast_channel.h" | 12 #include "chrome/common/extensions/api/cast_channel.h" |
| 14 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 14 #include "extensions/common/switches.h" |
| 15 #include "net/base/capturing_net_log.h" | 15 #include "net/base/capturing_net_log.h" |
| 16 #include "net/base/completion_callback.h" | 16 #include "net/base/completion_callback.h" |
| 17 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
| 18 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
| 19 | 19 |
| 20 namespace cast_channel = extensions::api::cast_channel; | 20 namespace cast_channel = extensions::api::cast_channel; |
| 21 using cast_channel::CastSocket; | 21 using cast_channel::CastSocket; |
| 22 using cast_channel::ChannelInfo; | 22 using cast_channel::ChannelInfo; |
| 23 using cast_channel::MessageInfo; | 23 using cast_channel::MessageInfo; |
| 24 | 24 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 67 |
| 68 } // namespace | 68 } // namespace |
| 69 | 69 |
| 70 class CastChannelAPITest : public ExtensionApiTest { | 70 class CastChannelAPITest : public ExtensionApiTest { |
| 71 public: | 71 public: |
| 72 CastChannelAPITest() {} | 72 CastChannelAPITest() {} |
| 73 | 73 |
| 74 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 74 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 75 ExtensionApiTest::SetUpCommandLine(command_line); | 75 ExtensionApiTest::SetUpCommandLine(command_line); |
| 76 command_line->AppendSwitchASCII( | 76 command_line->AppendSwitchASCII( |
| 77 switches::kWhitelistedExtensionID, kTestExtensionId); | 77 extensions::switches::kWhitelistedExtensionID, |
| 78 kTestExtensionId); |
| 78 } | 79 } |
| 79 | 80 |
| 80 void SetUpMockCastSocket() { | 81 void SetUpMockCastSocket() { |
| 81 extensions::CastChannelAPI* api = GetApi(); | 82 extensions::CastChannelAPI* api = GetApi(); |
| 82 mock_cast_socket_ = new MockCastSocket(api, &capturing_net_log_); | 83 mock_cast_socket_ = new MockCastSocket(api, &capturing_net_log_); |
| 83 // Transfers ownership of the socket. | 84 // Transfers ownership of the socket. |
| 84 api->SetSocketForTest( | 85 api->SetSocketForTest( |
| 85 make_scoped_ptr<CastSocket>(mock_cast_socket_).Pass()); | 86 make_scoped_ptr<CastSocket>(mock_cast_socket_).Pass()); |
| 86 } | 87 } |
| 87 | 88 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 WillOnce(InvokeCompletionCallback<0>(net::OK)); | 176 WillOnce(InvokeCompletionCallback<0>(net::OK)); |
| 176 | 177 |
| 177 EXPECT_TRUE(RunExtensionSubtest("cast_channel/api", | 178 EXPECT_TRUE(RunExtensionSubtest("cast_channel/api", |
| 178 "test_open_receive_close.html")); | 179 "test_open_receive_close.html")); |
| 179 | 180 |
| 180 ResultCatcher catcher; | 181 ResultCatcher catcher; |
| 181 CallOnMessage("some-message"); | 182 CallOnMessage("some-message"); |
| 182 CallOnMessage("some-message"); | 183 CallOnMessage("some-message"); |
| 183 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 184 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 184 } | 185 } |
| OLD | NEW |