Commit 15bb6732 authored by Aidan Wolter's avatar Aidan Wolter Committed by Commit Bot

Create TestInterfaceImpl for fuchsia tests

Multiple fuchsia tests may need to use base::fuchsia::TestInterfaceImpl,
so we are moving this class to it's own target for reusability. We are
also renaming it to TestInterfaceImpl to be more consistent with other
classes.

Bug: None
Test: base_unittests
Change-Id: Idff455a21a87cb74fc0de658aaa06b53b64126c0
Reviewed-on: https://chromium-review.googlesource.com/c/1406576
Commit-Queue: Aidan Wolter <awolter@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarWez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#624991}
parent 422db43a
......@@ -2232,6 +2232,18 @@ if (is_fuchsia) {
"fuchsia/test.fidl",
]
}
source_set("test_interface_impl") {
testonly = true
sources = [
"fuchsia/test_interface_impl.cc",
"fuchsia/test_interface_impl.h",
]
deps = [
":base",
":testfidl",
]
}
}
source_set("base_unittests_tasktraits") {
......@@ -2764,6 +2776,7 @@ test("base_unittests") {
sources -= [ "files/file_path_watcher_unittest.cc" ]
deps += [
":test_interface_impl",
":testfidl",
"//third_party/fuchsia-sdk/sdk:async",
"//third_party/fuchsia-sdk/sdk:async_default",
......
......@@ -9,14 +9,6 @@
namespace base {
namespace fuchsia {
TestInterfaceImpl::TestInterfaceImpl() = default;
TestInterfaceImpl::~TestInterfaceImpl() = default;
// TestInterface implementation.
void TestInterfaceImpl::Add(int32_t a, int32_t b, AddCallback callback) {
callback(a + b);
}
ServiceDirectoryTestBase::ServiceDirectoryTestBase() {
zx::channel service_directory_channel;
EXPECT_EQ(zx::channel::create(0, &service_directory_channel,
......
......@@ -9,6 +9,7 @@
#include "base/fuchsia/component_context.h"
#include "base/fuchsia/scoped_service_binding.h"
#include "base/fuchsia/test_interface_impl.h"
#include "base/fuchsia/testfidl/cpp/fidl.h"
#include "base/message_loop/message_loop.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -16,15 +17,6 @@
namespace base {
namespace fuchsia {
class TestInterfaceImpl : public testfidl::TestInterface {
public:
TestInterfaceImpl();
~TestInterfaceImpl() override;
// TestInterface implementation.
void Add(int32_t a, int32_t b, AddCallback callback) override;
};
class ServiceDirectoryTestBase : public testing::Test {
public:
ServiceDirectoryTestBase();
......
// Copyright 2018 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/fuchsia/test_interface_impl.h"
namespace base {
namespace fuchsia {
TestInterfaceImpl::TestInterfaceImpl() = default;
TestInterfaceImpl::~TestInterfaceImpl() = default;
void TestInterfaceImpl::Add(int32_t a, int32_t b, AddCallback callback) {
callback(a + b);
}
} // namespace fuchsia
} // namespace base
// Copyright 2018 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.
#ifndef BASE_FUCHSIA_FAKE_INTERFACE_IMPL_H_
#define BASE_FUCHSIA_FAKE_INTERFACE_IMPL_H_
#include <lib/fidl/cpp/binding_set.h>
#include <lib/zx/channel.h>
#include "base/fuchsia/testfidl/cpp/fidl.h"
namespace base {
namespace fuchsia {
class TestInterfaceImpl : public testfidl::TestInterface {
public:
TestInterfaceImpl();
~TestInterfaceImpl() override;
// TestInterface implementation:
void Add(int32_t a, int32_t b, AddCallback callback) override;
fidl::BindingSet<testfidl::TestInterface>* bindings() { return &bindings_; }
private:
fidl::BindingSet<testfidl::TestInterface> bindings_;
};
} // namespace fuchsia
} // namespace base
#endif // BASE_FUCHSIA_FAKE_INTERFACE_IMPL_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment