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

Side by Side Diff: cc/ipc/struct_traits_unittest.cc

Issue 2023973002: Introduce cc StructTraits unit tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved DEPS Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « cc/ipc/DEPS ('k') | cc/ipc/traits_test_service.mojom » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 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 "base/run_loop.h"
7 #include "cc/ipc/traits_test_service.mojom.h"
8 #include "cc/quads/render_pass_id.h"
9 #include "mojo/public/cpp/bindings/binding_set.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace cc {
13
14 namespace {
15
16 class StructTraitsTest : public testing::Test, public mojom::TraitsTestService {
17 public:
18 StructTraitsTest() {}
19
20 protected:
21 mojom::TraitsTestServicePtr GetTraitsTestProxy() {
22 return traits_test_bindings_.CreateInterfacePtrAndBind(this);
23 }
24
25 private:
26 // TraitsTestService:
27 void EchoRenderPassId(const RenderPassId& r,
28 const EchoRenderPassIdCallback& callback) override {
29 callback.Run(r);
30 }
31
32 void EchoSurfaceId(const SurfaceId& s,
33 const EchoSurfaceIdCallback& callback) override {
34 callback.Run(s);
35 }
36
37 mojo::BindingSet<TraitsTestService> traits_test_bindings_;
38 };
39
40 } // namespace
41
42 TEST_F(StructTraitsTest, RenderPassId) {
43 const int layer_id = 1337;
44 const uint32_t index = 0xdeadbeef;
45 RenderPassId input(layer_id, index);
46 base::RunLoop loop;
47 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
48 proxy->EchoRenderPassId(input,
49 [layer_id, index, &loop](const RenderPassId& pass) {
50 EXPECT_EQ(layer_id, pass.layer_id);
51 EXPECT_EQ(index, pass.index);
52 loop.Quit();
53 });
54 loop.Run();
55 }
56
57 TEST_F(StructTraitsTest, SurfaceId) {
58 const uint32_t id_namespace = 1337;
59 const uint32_t local_id = 0xfbadbeef;
60 const uint64_t nonce = 0xdeadbeef;
61 SurfaceId input(id_namespace, local_id, nonce);
62 base::RunLoop loop;
63 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
64 proxy->EchoSurfaceId(
65 input, [id_namespace, local_id, nonce, &loop](const SurfaceId& pass) {
66 EXPECT_EQ(id_namespace, pass.id_namespace());
67 EXPECT_EQ(local_id, pass.local_id());
68 EXPECT_EQ(nonce, pass.nonce());
69 loop.Quit();
70 });
71 loop.Run();
72 }
73
74 } // namespace cc
OLDNEW
« no previous file with comments | « cc/ipc/DEPS ('k') | cc/ipc/traits_test_service.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698