| 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" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 using ::testing::_; | 32 using ::testing::_; |
| 33 using ::testing::A; | 33 using ::testing::A; |
| 34 using ::testing::DoAll; | 34 using ::testing::DoAll; |
| 35 using ::testing::Invoke; | 35 using ::testing::Invoke; |
| 36 using ::testing::InSequence; | 36 using ::testing::InSequence; |
| 37 using ::testing::Return; | 37 using ::testing::Return; |
| 38 | 38 |
| 39 namespace { | 39 namespace { |
| 40 | 40 |
| 41 const char kTestExtensionId[] = "ddchlicdkolnonkihahngkmmmjnjlkkf"; | 41 const char kTestExtensionId[] = "ddchlicdkolnonkihahngkmmmjnjlkkf"; |
| 42 const int64 kTimeoutMs = 10000; |
| 42 | 43 |
| 43 static void FillMessageInfo(MessageInfo* message_info, | 44 static void FillMessageInfo(MessageInfo* message_info, |
| 44 const std::string& message) { | 45 const std::string& message) { |
| 45 message_info->namespace_ = "foo"; | 46 message_info->namespace_ = "foo"; |
| 46 message_info->source_id = "src"; | 47 message_info->source_id = "src"; |
| 47 message_info->destination_id = "dest"; | 48 message_info->destination_id = "dest"; |
| 48 message_info->data.reset(new base::StringValue(message)); | 49 message_info->data.reset(new base::StringValue(message)); |
| 49 } | 50 } |
| 50 | 51 |
| 51 ACTION_TEMPLATE(InvokeCompletionCallback, | 52 ACTION_TEMPLATE(InvokeCompletionCallback, |
| 52 HAS_1_TEMPLATE_PARAMS(int, k), | 53 HAS_1_TEMPLATE_PARAMS(int, k), |
| 53 AND_1_VALUE_PARAMS(result)) { | 54 AND_1_VALUE_PARAMS(result)) { |
| 54 ::std::tr1::get<k>(args).Run(result); | 55 ::std::tr1::get<k>(args).Run(result); |
| 55 } | 56 } |
| 56 | 57 |
| 57 ACTION_P2(InvokeDelegateOnError, api_test, api) { | 58 ACTION_P2(InvokeDelegateOnError, api_test, api) { |
| 58 api_test->CallOnError(api); | 59 api_test->CallOnError(api); |
| 59 } | 60 } |
| 60 | 61 |
| 61 class MockCastSocket : public CastSocket { | 62 class MockCastSocket : public CastSocket { |
| 62 public: | 63 public: |
| 63 explicit MockCastSocket(CastSocket::Delegate* delegate, | 64 explicit MockCastSocket(CastSocket::Delegate* delegate, |
| 64 net::IPEndPoint ip_endpoint, | 65 net::IPEndPoint ip_endpoint, |
| 65 net::NetLog* net_log) | 66 net::NetLog* net_log) |
| 66 : CastSocket(kTestExtensionId, ip_endpoint, | 67 : CastSocket(kTestExtensionId, ip_endpoint, |
| 67 cast_channel::CHANNEL_AUTH_TYPE_SSL, delegate, net_log) {} | 68 cast_channel::CHANNEL_AUTH_TYPE_SSL, delegate, net_log, |
| 69 base::TimeDelta::FromMilliseconds(kTimeoutMs)) {} |
| 68 virtual ~MockCastSocket() {} | 70 virtual ~MockCastSocket() {} |
| 69 | 71 |
| 70 virtual bool CalledOnValidThread() const OVERRIDE { | 72 virtual bool CalledOnValidThread() const OVERRIDE { |
| 71 // Always return true in testing. | 73 // Always return true in testing. |
| 72 return true; | 74 return true; |
| 73 } | 75 } |
| 74 | 76 |
| 75 MOCK_METHOD1(Connect, void(const net::CompletionCallback& callback)); | 77 MOCK_METHOD1(Connect, void(const net::CompletionCallback& callback)); |
| 76 MOCK_METHOD2(SendMessage, void(const MessageInfo& message, | 78 MOCK_METHOD2(SendMessage, void(const MessageInfo& message, |
| 77 const net::CompletionCallback& callback)); | 79 const net::CompletionCallback& callback)); |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 cast_channel_send_function.get(), | 375 cast_channel_send_function.get(), |
| 374 "[{\"channelId\": 1, \"url\": \"cast://127.0.0.1:8009\", " | 376 "[{\"channelId\": 1, \"url\": \"cast://127.0.0.1:8009\", " |
| 375 "\"connectInfo\": " | 377 "\"connectInfo\": " |
| 376 "{\"ipAddress\": \"127.0.0.1\", \"port\": 8009, " | 378 "{\"ipAddress\": \"127.0.0.1\", \"port\": 8009, " |
| 377 "\"auth\": \"ssl\"}, \"readyState\": \"open\"}, " | 379 "\"auth\": \"ssl\"}, \"readyState\": \"open\"}, " |
| 378 "{\"namespace_\": \"foo\", \"sourceId\": \"src\", " | 380 "{\"namespace_\": \"foo\", \"sourceId\": \"src\", " |
| 379 "\"destinationId\": \"\", \"data\": \"data\"}]", | 381 "\"destinationId\": \"\", \"data\": \"data\"}]", |
| 380 browser()); | 382 browser()); |
| 381 EXPECT_EQ(error, "message_info.destination_id is required"); | 383 EXPECT_EQ(error, "message_info.destination_id is required"); |
| 382 } | 384 } |
| OLD | NEW |