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

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: Addressed Ken's comment 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
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, [&](const RenderPassId& pass) {
Tom Sepez 2016/05/31 16:07:43 I'd expect we'd capture layer_id and index by valu
Fady Samuel 2016/05/31 16:37:09 I'm passing all of input by value now. WDYT?
49 EXPECT_EQ(input.layer_id, pass.layer_id);
50 EXPECT_EQ(input.index, pass.index);
51 loop.Quit();
52 });
53 loop.Run();
54 }
55
56 TEST_F(StructTraitsTest, SurfaceId) {
57 const uint32_t id_namespace = 1337;
58 const uint32_t local_id = 0xfbadbeef;
59 const uint64_t nonce = 0xdeadbeef;
60 SurfaceId input(id_namespace, local_id, nonce);
61 base::RunLoop loop;
62 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
63 proxy->EchoSurfaceId(input, [&](const SurfaceId& pass) {
64 EXPECT_EQ(input.id_namespace(), pass.id_namespace());
Tom Sepez 2016/05/31 16:07:42 same here.
Fady Samuel 2016/05/31 16:37:09 Passing input by value.
65 EXPECT_EQ(input.local_id(), pass.local_id());
66 EXPECT_EQ(input.nonce(), pass.nonce());
67 loop.Quit();
68 });
69 loop.Run();
70 }
71
72 } // namespace cc
OLDNEW
« cc/cc_tests.gyp ('K') | « 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