Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Side by Side Diff: extensions/browser/api/cast_channel/cast_socket_unittest.cc

Issue 395333003: Extensions: Move cast_channel and hid APIs to extensions/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « extensions/browser/api/cast_channel/cast_socket.cc ('k') | extensions/browser/api/hid/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/extensions/api/cast_channel/cast_socket.h" 5 #include "extensions/browser/api/cast_channel/cast_socket.h"
6 6
7 #include "base/memory/weak_ptr.h" 7 #include "base/memory/weak_ptr.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/sys_byteorder.h" 11 #include "base/sys_byteorder.h"
12 #include "base/timer/mock_timer.h" 12 #include "base/timer/mock_timer.h"
13 #include "chrome/browser/extensions/api/cast_channel/cast_channel.pb.h" 13 #include "extensions/browser/api/cast_channel/cast_channel.pb.h"
14 #include "chrome/browser/extensions/api/cast_channel/cast_message_util.h" 14 #include "extensions/browser/api/cast_channel/cast_message_util.h"
15 #include "net/base/address_list.h" 15 #include "net/base/address_list.h"
16 #include "net/base/capturing_net_log.h" 16 #include "net/base/capturing_net_log.h"
17 #include "net/base/net_errors.h" 17 #include "net/base/net_errors.h"
18 #include "net/base/net_util.h" 18 #include "net/base/net_util.h"
19 #include "net/socket/socket_test_util.h" 19 #include "net/socket/socket_test_util.h"
20 #include "net/socket/ssl_client_socket.h" 20 #include "net/socket/ssl_client_socket.h"
21 #include "net/socket/tcp_client_socket.h" 21 #include "net/socket/tcp_client_socket.h"
22 #include "net/ssl/ssl_info.h" 22 #include "net/ssl/ssl_info.h"
23 #include "testing/gmock/include/gmock/gmock.h" 23 #include "testing/gmock/include/gmock/gmock.h"
24 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
25 25
26 const int64 kDistantTimeoutMillis = 100000; // 100 seconds (never hit). 26 const int64 kDistantTimeoutMillis = 100000; // 100 seconds (never hit).
27 27
28 using ::testing::_; 28 using ::testing::_;
29 using ::testing::A; 29 using ::testing::A;
30 using ::testing::DoAll; 30 using ::testing::DoAll;
31 using ::testing::Return; 31 using ::testing::Return;
32 using ::testing::SaveArg; 32 using ::testing::SaveArg;
33 33
34 namespace { 34 namespace {
35 const char* kTestData[4] = { 35 const char* kTestData[4] = {
36 "Hello, World!", 36 "Hello, World!",
37 "Goodbye, World!", 37 "Goodbye, World!",
38 "Hello, Sky!", 38 "Hello, Sky!",
39 "Goodbye, Volcano!", 39 "Goodbye, Volcano!",
40 }; 40 };
41 } // namespace 41 } // namespace
42 42
43 namespace extensions { 43 namespace extensions {
44 namespace api { 44 namespace core_api {
45 namespace cast_channel { 45 namespace cast_channel {
46 46
47 // Fills in |message| with a string message. 47 // Fills in |message| with a string message.
48 static void CreateStringMessage(const std::string& namespace_, 48 static void CreateStringMessage(const std::string& namespace_,
49 const std::string& source_id, 49 const std::string& source_id,
50 const std::string& destination_id, 50 const std::string& destination_id,
51 const std::string& data, 51 const std::string& data,
52 MessageInfo* message) { 52 MessageInfo* message) {
53 message->namespace_ = namespace_; 53 message->namespace_ = namespace_;
54 message->source_id = source_id; 54 message->source_id = source_id;
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 EXPECT_CALL(handler_, OnWriteComplete(net::ERR_FAILED)); 830 EXPECT_CALL(handler_, OnWriteComplete(net::ERR_FAILED));
831 size_t size = CastSocket::MessageHeader::max_message_size() + 1; 831 size_t size = CastSocket::MessageHeader::max_message_size() + 1;
832 test_messages_[0].data.reset( 832 test_messages_[0].data.reset(
833 new base::StringValue(std::string(size, 'a'))); 833 new base::StringValue(std::string(size, 'a')));
834 socket_->SendMessage(test_messages_[0], 834 socket_->SendMessage(test_messages_[0],
835 base::Bind(&CompleteHandler::OnWriteComplete, 835 base::Bind(&CompleteHandler::OnWriteComplete,
836 base::Unretained(&handler_))); 836 base::Unretained(&handler_)));
837 837
838 EXPECT_EQ(cast_channel::READY_STATE_OPEN, socket_->ready_state()); 838 EXPECT_EQ(cast_channel::READY_STATE_OPEN, socket_->ready_state());
839 EXPECT_EQ(cast_channel::CHANNEL_ERROR_NONE, socket_->error_state()); 839 EXPECT_EQ(cast_channel::CHANNEL_ERROR_NONE, socket_->error_state());
840
841 } 840 }
842 841
843 // Test write error - network error (sync) 842 // Test write error - network error (sync)
844 TEST_F(CastSocketTest, TestWriteNetworkErrorSync) { 843 TEST_F(CastSocketTest, TestWriteNetworkErrorSync) {
845 CreateCastSocket(); 844 CreateCastSocket();
846 socket_->AddWriteResult(net::SYNCHRONOUS, net::ERR_FAILED); 845 socket_->AddWriteResult(net::SYNCHRONOUS, net::ERR_FAILED);
847 ConnectHelper(); 846 ConnectHelper();
848 847
849 EXPECT_CALL(handler_, OnWriteComplete(net::ERR_FAILED)); 848 EXPECT_CALL(handler_, OnWriteComplete(net::ERR_FAILED));
850 EXPECT_CALL(mock_delegate_, 849 EXPECT_CALL(mock_delegate_,
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 OnError(socket_.get(), 1052 OnError(socket_.get(),
1054 cast_channel::CHANNEL_ERROR_INVALID_MESSAGE)); 1053 cast_channel::CHANNEL_ERROR_INVALID_MESSAGE));
1055 ConnectHelper(); 1054 ConnectHelper();
1056 1055
1057 EXPECT_EQ(cast_channel::READY_STATE_CLOSED, socket_->ready_state()); 1056 EXPECT_EQ(cast_channel::READY_STATE_CLOSED, socket_->ready_state());
1058 EXPECT_EQ(cast_channel::CHANNEL_ERROR_INVALID_MESSAGE, 1057 EXPECT_EQ(cast_channel::CHANNEL_ERROR_INVALID_MESSAGE,
1059 socket_->error_state()); 1058 socket_->error_state());
1060 } 1059 }
1061 1060
1062 } // namespace cast_channel 1061 } // namespace cast_channel
1063 } // namespace api 1062 } // namespace core_api
1064 } // namespace extensions 1063 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/cast_channel/cast_socket.cc ('k') | extensions/browser/api/hid/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698