| 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 "extensions/browser/api/cast_channel/cast_socket.h" | 5 #include "extensions/browser/api/cast_channel/cast_socket.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 bool tcp_unresponsive_; | 342 bool tcp_unresponsive_; |
| 343 scoped_ptr<base::MockTimer> mock_timer_; | 343 scoped_ptr<base::MockTimer> mock_timer_; |
| 344 }; | 344 }; |
| 345 | 345 |
| 346 class CastSocketTest : public testing::Test { | 346 class CastSocketTest : public testing::Test { |
| 347 public: | 347 public: |
| 348 CastSocketTest() | 348 CastSocketTest() |
| 349 : logger_(new Logger( | 349 : logger_(new Logger( |
| 350 scoped_ptr<base::TickClock>(new base::SimpleTestTickClock), | 350 scoped_ptr<base::TickClock>(new base::SimpleTestTickClock), |
| 351 base::TimeTicks())) {} | 351 base::TimeTicks())) {} |
| 352 virtual ~CastSocketTest() {} | 352 ~CastSocketTest() override {} |
| 353 | 353 |
| 354 virtual void SetUp() override { | 354 void SetUp() override { |
| 355 // Create a few test messages | 355 // Create a few test messages |
| 356 for (size_t i = 0; i < arraysize(test_messages_); i++) { | 356 for (size_t i = 0; i < arraysize(test_messages_); i++) { |
| 357 CreateStringMessage("urn:cast", "1", "2", kTestData[i], | 357 CreateStringMessage("urn:cast", "1", "2", kTestData[i], |
| 358 &test_messages_[i]); | 358 &test_messages_[i]); |
| 359 ASSERT_TRUE(MessageInfoToCastMessage( | 359 ASSERT_TRUE(MessageInfoToCastMessage( |
| 360 test_messages_[i], &test_protos_[i])); | 360 test_messages_[i], &test_protos_[i])); |
| 361 ASSERT_TRUE( | 361 ASSERT_TRUE( |
| 362 MessageFramer::Serialize(test_protos_[i], &test_proto_strs_[i])); | 362 MessageFramer::Serialize(test_protos_[i], &test_proto_strs_[i])); |
| 363 } | 363 } |
| 364 } | 364 } |
| 365 | 365 |
| 366 virtual void TearDown() override { | 366 void TearDown() override { |
| 367 if (socket_.get()) { | 367 if (socket_.get()) { |
| 368 EXPECT_CALL(handler_, OnCloseComplete(net::OK)); | 368 EXPECT_CALL(handler_, OnCloseComplete(net::OK)); |
| 369 socket_->Close(base::Bind(&CompleteHandler::OnCloseComplete, | 369 socket_->Close(base::Bind(&CompleteHandler::OnCloseComplete, |
| 370 base::Unretained(&handler_))); | 370 base::Unretained(&handler_))); |
| 371 } | 371 } |
| 372 } | 372 } |
| 373 | 373 |
| 374 // The caller can specify non-standard namespaces by setting "auth_namespace" | 374 // The caller can specify non-standard namespaces by setting "auth_namespace" |
| 375 // (useful for negative test cases.) | 375 // (useful for negative test cases.) |
| 376 void SetupAuthMessage( | 376 void SetupAuthMessage( |
| (...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1201 A<const LastErrors&>())); | 1201 A<const LastErrors&>())); |
| 1202 ConnectHelper(); | 1202 ConnectHelper(); |
| 1203 | 1203 |
| 1204 EXPECT_EQ(cast_channel::READY_STATE_CLOSED, socket_->ready_state()); | 1204 EXPECT_EQ(cast_channel::READY_STATE_CLOSED, socket_->ready_state()); |
| 1205 EXPECT_EQ(cast_channel::CHANNEL_ERROR_INVALID_MESSAGE, | 1205 EXPECT_EQ(cast_channel::CHANNEL_ERROR_INVALID_MESSAGE, |
| 1206 socket_->error_state()); | 1206 socket_->error_state()); |
| 1207 } | 1207 } |
| 1208 } // namespace cast_channel | 1208 } // namespace cast_channel |
| 1209 } // namespace core_api | 1209 } // namespace core_api |
| 1210 } // namespace extensions | 1210 } // namespace extensions |
| OLD | NEW |