summaryrefslogtreecommitdiffstats
path: root/chromeos/binder/command_broker_unittest.cc
blob: f5b8b19eee3af26b3c479564a4c4650e2185c08c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// 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/constants.h"
#include "chromeos/binder/driver.h"
#include "chromeos/binder/transaction_data.h"
#include "chromeos/binder/writable_transaction_data.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace binder {

class BinderCommandBrokerTest : public ::testing::Test {
 public:
  BinderCommandBrokerTest() : command_broker_(&driver_) {}
  ~BinderCommandBrokerTest() override {}

  void SetUp() override { ASSERT_TRUE(driver_.Initialize()); }

 protected:
  base::MessageLoop message_loop_;
  Driver driver_;
  CommandBroker command_broker_;
};

TEST_F(BinderCommandBrokerTest, Transact) {
  WritableTransactionData data;
  data.SetCode(kPingTransactionCode);
  scoped_ptr<TransactionData> reply;
  EXPECT_TRUE(command_broker_.Transact(kContextManagerHandle, data, &reply));
  ASSERT_TRUE(reply);
  EXPECT_FALSE(reply->HasStatus());  // No error.
}

}  // namespace binder