| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <unistd.h> | 5 #include <unistd.h> |
| 6 #include <linux/android/binder.h> | 6 #include <linux/android/binder.h> |
| 7 | 7 |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "chromeos/binder/command_stream.h" | 9 #include "chromeos/binder/command_stream.h" |
| 10 #include "chromeos/binder/constants.h" | 10 #include "chromeos/binder/constants.h" |
| 11 #include "chromeos/binder/driver.h" | 11 #include "chromeos/binder/driver.h" |
| 12 #include "chromeos/binder/transaction_data.h" | 12 #include "chromeos/binder/transaction_data.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 namespace binder { | 15 namespace binder { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 class BinderCommandStreamTest : public ::testing::Test, | 19 class BinderCommandStreamTest : public ::testing::Test, |
| 20 public CommandStream::IncomingCommandHandler { | 20 public CommandStream::IncomingCommandHandler { |
| 21 public: | 21 public: |
| 22 BinderCommandStreamTest() : command_stream_(&driver_, this) {} | 22 BinderCommandStreamTest() : command_stream_(&driver_, this) {} |
| 23 ~BinderCommandStreamTest() override {} | 23 ~BinderCommandStreamTest() override {} |
| 24 | 24 |
| 25 void SetUp() override { ASSERT_TRUE(driver_.Initialize()); } | 25 void SetUp() override { ASSERT_TRUE(driver_.Initialize()); } |
| 26 | 26 |
| 27 // CommandStream::IncomingCommandHandler override: | 27 // CommandStream::IncomingCommandHandler override: |
| 28 bool OnTransaction(const TransactionData& data) override { return false; } |
| 29 |
| 28 void OnReply(scoped_ptr<TransactionData> data) override { | 30 void OnReply(scoped_ptr<TransactionData> data) override { |
| 29 received_response_ = RESPONSE_REPLY; | 31 received_response_ = RESPONSE_REPLY; |
| 30 ASSERT_TRUE(data); | 32 ASSERT_TRUE(data); |
| 31 EXPECT_FALSE(data->HasStatus()); // No error. | 33 EXPECT_FALSE(data->HasStatus()); // No error. |
| 32 } | 34 } |
| 33 | 35 |
| 34 void OnDeadReply() override { received_response_ = RESPONSE_DEAD; } | 36 void OnDeadReply() override { received_response_ = RESPONSE_DEAD; } |
| 35 | 37 |
| 36 void OnTransactionComplete() override { | 38 void OnTransactionComplete() override { |
| 37 received_response_ = RESPONSE_COMPLETE; | 39 received_response_ = RESPONSE_COMPLETE; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 if (command_stream_.CanProcessIncomingCommand()) { | 105 if (command_stream_.CanProcessIncomingCommand()) { |
| 104 ASSERT_TRUE(command_stream_.ProcessIncomingCommand()); | 106 ASSERT_TRUE(command_stream_.ProcessIncomingCommand()); |
| 105 } else { | 107 } else { |
| 106 ASSERT_TRUE(command_stream_.Fetch()); | 108 ASSERT_TRUE(command_stream_.Fetch()); |
| 107 } | 109 } |
| 108 } | 110 } |
| 109 ASSERT_EQ(RESPONSE_REPLY, received_response_); | 111 ASSERT_EQ(RESPONSE_REPLY, received_response_); |
| 110 } | 112 } |
| 111 | 113 |
| 112 } // namespace binder | 114 } // namespace binder |
| OLD | NEW |