Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/message_loop/message_loop.h" | |
| 6 #include "chromeos/binder/command_broker.h" | |
| 7 #include "chromeos/binder/driver.h" | |
| 8 #include "chromeos/binder/object.h" | |
| 9 #include "chromeos/binder/service_manager_proxy.h" | |
| 10 #include "chromeos/binder/test_service.h" | |
| 11 #include "chromeos/binder/transaction_data.h" | |
| 12 #include "chromeos/binder/transaction_data_reader.h" | |
| 13 #include "chromeos/binder/writable_transaction_data.h" | |
| 14 #include "testing/gtest/include/gtest/gtest.h" | |
| 15 | |
| 16 namespace binder { | |
| 17 | |
| 18 class BinderEndToEndTest : public ::testing::Test { | |
| 19 public: | |
| 20 BinderEndToEndTest() : command_broker_(&driver_) {} | |
| 21 | |
| 22 void SetUp() override { | |
| 23 ASSERT_TRUE(driver_.Initialize()); | |
| 24 | |
| 25 // Start the test service and get a remote object from it. | |
| 26 ASSERT_TRUE(test_service_.StartAndWait()); | |
| 27 remote_object_ = ServiceManagerProxy::CheckService( | |
| 28 &command_broker_, test_service_.service_name()); | |
| 29 ASSERT_TRUE(remote_object_); | |
| 30 } | |
| 31 | |
| 32 protected: | |
| 33 base::MessageLoopForIO message_loop_; | |
| 34 Driver driver_; | |
| 35 CommandBroker command_broker_; | |
| 36 TestService test_service_; | |
| 37 scoped_refptr<Object> remote_object_; | |
| 38 }; | |
| 39 | |
| 40 TEST_F(BinderEndToEndTest, IncrementInt) { | |
|
satorux1
2016/01/13 04:33:20
nice!
hashimoto
2016/01/13 05:46:46
Yey, finally!
| |
| 41 const int32_t kInput = 42; | |
| 42 WritableTransactionData data; | |
| 43 data.SetCode(TestService::INCREMENT_INT_TRANSACTION); | |
| 44 data.WriteInt32(kInput); | |
| 45 scoped_ptr<TransactionData> reply; | |
| 46 ASSERT_TRUE(remote_object_->Transact(&command_broker_, data, &reply)); | |
| 47 ASSERT_TRUE(reply); | |
| 48 | |
| 49 TransactionDataReader reader(*reply); | |
| 50 int32_t result = 0; | |
| 51 EXPECT_TRUE(reader.ReadInt32(&result)); | |
| 52 EXPECT_EQ(kInput + 1, result); | |
| 53 } | |
| 54 | |
| 55 } // namespace binder | |
| OLD | NEW |