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

Unified Diff: chromeos/binder/end_to_end_unittest.cc

Issue 1575313002: Add CommandBroker::OnTransaction to handle incoming transactions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comment Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/binder/command_stream_unittest.cc ('k') | chromeos/binder/ipc_thread.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/binder/end_to_end_unittest.cc
diff --git a/chromeos/binder/end_to_end_unittest.cc b/chromeos/binder/end_to_end_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..adfd634e5de8dfb8de19cecb729505c7a7c0851e
--- /dev/null
+++ b/chromeos/binder/end_to_end_unittest.cc
@@ -0,0 +1,56 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/message_loop/message_loop.h"
+#include "chromeos/binder/command_broker.h"
+#include "chromeos/binder/driver.h"
+#include "chromeos/binder/object.h"
+#include "chromeos/binder/service_manager_proxy.h"
+#include "chromeos/binder/test_service.h"
+#include "chromeos/binder/transaction_data.h"
+#include "chromeos/binder/transaction_data_reader.h"
+#include "chromeos/binder/writable_transaction_data.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace binder {
+
+class BinderEndToEndTest : public ::testing::Test {
+ public:
+ BinderEndToEndTest() : command_broker_(&driver_) {}
+
+ void SetUp() override {
+ ASSERT_TRUE(driver_.Initialize());
+
+ // Start the test service and get a remote object from it.
+ ASSERT_TRUE(test_service_.StartAndWait());
+ remote_object_ = ServiceManagerProxy::CheckService(
+ &command_broker_, test_service_.service_name());
+ ASSERT_EQ(Object::TYPE_REMOTE, remote_object_->GetType());
+ ASSERT_TRUE(remote_object_);
+ }
+
+ protected:
+ base::MessageLoopForIO message_loop_;
+ Driver driver_;
+ CommandBroker command_broker_;
+ TestService test_service_;
+ scoped_refptr<Object> remote_object_;
+};
+
+TEST_F(BinderEndToEndTest, IncrementInt) {
+ const int32_t kInput = 42;
+ WritableTransactionData data;
+ data.SetCode(TestService::INCREMENT_INT_TRANSACTION);
+ data.WriteInt32(kInput);
+ scoped_ptr<TransactionData> reply;
+ ASSERT_TRUE(remote_object_->Transact(&command_broker_, data, &reply));
+ ASSERT_TRUE(reply);
+
+ TransactionDataReader reader(*reply);
+ int32_t result = 0;
+ EXPECT_TRUE(reader.ReadInt32(&result));
+ EXPECT_EQ(kInput + 1, result);
+}
+
+} // namespace binder
« no previous file with comments | « chromeos/binder/command_stream_unittest.cc ('k') | chromeos/binder/ipc_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698