Commit 410c960e authored by fsamuel's avatar fsamuel Committed by Commit bot

Introduce cc StructTraits unit tests

BUG=611802
TBR=danakj@chromium.org for cc/test
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel

Review-Url: https://codereview.chromium.org/2023973002
Cr-Commit-Position: refs/heads/master@{#396941}
parent 028a16f9
......@@ -800,6 +800,7 @@ test("cc_unittests") {
"input/scrollbar_animation_controller_thinning_unittest.cc",
"input/top_controls_manager_unittest.cc",
"ipc/cc_param_traits_unittest.cc",
"ipc/struct_traits_unittest.cc",
"layers/heads_up_display_layer_impl_unittest.cc",
"layers/heads_up_display_unittest.cc",
"layers/layer_impl_unittest.cc",
......@@ -949,6 +950,7 @@ test("cc_unittests") {
":test_support",
"//base/test:test_support",
"//cc/ipc",
"//cc/ipc:test_interfaces",
"//cc/proto",
"//cc/surfaces",
"//cc/surfaces:surface_id",
......@@ -957,6 +959,8 @@ test("cc_unittests") {
"//gpu/command_buffer/client:gles2_interface",
"//gpu/command_buffer/common:gles2_utils",
"//media",
"//mojo/edk/system",
"//mojo/public/cpp/bindings",
"//testing/gmock",
"//testing/gtest",
"//ui/events:events_base",
......
......@@ -338,6 +338,8 @@
'../gpu/gpu.gyp:gpu_unittest_utils',
'../ipc/ipc.gyp:ipc',
'../media/media.gyp:media',
'../mojo/mojo_edk.gyp:mojo_common_test_support',
'../mojo/mojo_public.gyp:mojo_cpp_bindings',
'../skia/skia.gyp:skia',
'../testing/gmock.gyp:gmock',
'../testing/gtest.gyp:gtest',
......
......@@ -40,3 +40,14 @@ mojom("interfaces") {
"surface_id.mojom",
]
}
mojom("test_interfaces") {
testonly = true
sources = [
"traits_test_service.mojom",
]
public_deps = [
":interfaces",
]
}
include_rules = [
"+gpu/ipc/common",
"+mojo/public",
"+ui/events/ipc",
]
// Copyright 2016 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 "base/run_loop.h"
#include "cc/ipc/traits_test_service.mojom.h"
#include "cc/quads/render_pass_id.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace cc {
namespace {
class StructTraitsTest : public testing::Test, public mojom::TraitsTestService {
public:
StructTraitsTest() {}
protected:
mojom::TraitsTestServicePtr GetTraitsTestProxy() {
return traits_test_bindings_.CreateInterfacePtrAndBind(this);
}
private:
// TraitsTestService:
void EchoRenderPassId(const RenderPassId& r,
const EchoRenderPassIdCallback& callback) override {
callback.Run(r);
}
void EchoSurfaceId(const SurfaceId& s,
const EchoSurfaceIdCallback& callback) override {
callback.Run(s);
}
mojo::BindingSet<TraitsTestService> traits_test_bindings_;
};
} // namespace
TEST_F(StructTraitsTest, RenderPassId) {
const int layer_id = 1337;
const uint32_t index = 0xdeadbeef;
RenderPassId input(layer_id, index);
base::RunLoop loop;
mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
proxy->EchoRenderPassId(input,
[layer_id, index, &loop](const RenderPassId& pass) {
EXPECT_EQ(layer_id, pass.layer_id);
EXPECT_EQ(index, pass.index);
loop.Quit();
});
loop.Run();
}
TEST_F(StructTraitsTest, SurfaceId) {
const uint32_t id_namespace = 1337;
const uint32_t local_id = 0xfbadbeef;
const uint64_t nonce = 0xdeadbeef;
SurfaceId input(id_namespace, local_id, nonce);
base::RunLoop loop;
mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
proxy->EchoSurfaceId(
input, [id_namespace, local_id, nonce, &loop](const SurfaceId& pass) {
EXPECT_EQ(id_namespace, pass.id_namespace());
EXPECT_EQ(local_id, pass.local_id());
EXPECT_EQ(nonce, pass.nonce());
loop.Quit();
});
loop.Run();
}
} // namespace cc
// Copyright 2016 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.
module cc.mojom;
import "cc/ipc/render_pass_id.mojom";
import "cc/ipc/surface_id.mojom";
interface TraitsTestService {
EchoRenderPassId(RenderPassId r) => (RenderPassId pass);
EchoSurfaceId(SurfaceId s) => (SurfaceId pass);
};
......@@ -8,3 +8,9 @@ include_rules = [
"+gpu/command_buffer/service/image_factory.h",
"+gpu/skia_bindings/grcontext_for_gles2_interface.h",
]
specific_include_rules = {
"run_all_unittests\.cc": [
"+mojo/edk/embedder/embedder.h",
],
}
......@@ -5,10 +5,13 @@
#include "base/bind.h"
#include "base/test/launcher/unit_test_launcher.h"
#include "cc/test/cc_test_suite.h"
#include "mojo/edk/embedder/embedder.h"
int main(int argc, char** argv) {
cc::CCTestSuite test_suite(argc, argv);
mojo::edk::Init();
return base::LaunchUnitTests(
argc,
argv,
......
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