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

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

Issue 2041503002: Implement cc::Selection<gfx::SelectionBound> StructTraits (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix 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/selection_struct_traits.h ('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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/message_loop/message_loop.h" 5 #include "base/message_loop/message_loop.h"
6 #include "cc/input/selection.h"
6 #include "cc/ipc/traits_test_service.mojom.h" 7 #include "cc/ipc/traits_test_service.mojom.h"
7 #include "cc/quads/render_pass_id.h" 8 #include "cc/quads/render_pass_id.h"
8 #include "mojo/public/cpp/bindings/binding_set.h" 9 #include "mojo/public/cpp/bindings/binding_set.h"
9 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
10 11
11 namespace cc { 12 namespace cc {
12 13
13 namespace { 14 namespace {
14 15
15 class StructTraitsTest : public testing::Test, public mojom::TraitsTestService { 16 class StructTraitsTest : public testing::Test, public mojom::TraitsTestService {
(...skipping 16 matching lines...) Expand all
32 const EchoRenderPassIdCallback& callback) override { 33 const EchoRenderPassIdCallback& callback) override {
33 callback.Run(r); 34 callback.Run(r);
34 } 35 }
35 36
36 void EchoReturnedResource( 37 void EchoReturnedResource(
37 const ReturnedResource& r, 38 const ReturnedResource& r,
38 const EchoReturnedResourceCallback& callback) override { 39 const EchoReturnedResourceCallback& callback) override {
39 callback.Run(r); 40 callback.Run(r);
40 } 41 }
41 42
43 void EchoSelection(const Selection<gfx::SelectionBound>& s,
44 const EchoSelectionCallback& callback) override {
45 callback.Run(s);
46 }
47
42 void EchoSharedQuadState( 48 void EchoSharedQuadState(
43 const SharedQuadState& s, 49 const SharedQuadState& s,
44 const EchoSharedQuadStateCallback& callback) override { 50 const EchoSharedQuadStateCallback& callback) override {
45 callback.Run(s); 51 callback.Run(s);
46 } 52 }
47 53
48 void EchoSurfaceId(const SurfaceId& s, 54 void EchoSurfaceId(const SurfaceId& s,
49 const EchoSurfaceIdCallback& callback) override { 55 const EchoSurfaceIdCallback& callback) override {
50 callback.Run(s); 56 callback.Run(s);
51 } 57 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 input.lost = lost; 120 input.lost = lost;
115 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); 121 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
116 ReturnedResource output; 122 ReturnedResource output;
117 proxy->EchoReturnedResource(input, &output); 123 proxy->EchoReturnedResource(input, &output);
118 EXPECT_EQ(id, output.id); 124 EXPECT_EQ(id, output.id);
119 EXPECT_EQ(sync_token, output.sync_token); 125 EXPECT_EQ(sync_token, output.sync_token);
120 EXPECT_EQ(count, output.count); 126 EXPECT_EQ(count, output.count);
121 EXPECT_EQ(lost, output.lost); 127 EXPECT_EQ(lost, output.lost);
122 } 128 }
123 129
130 TEST_F(StructTraitsTest, Selection) {
131 gfx::SelectionBound start;
132 start.SetEdge(gfx::PointF(1234.5f, 67891.f), gfx::PointF(5432.1f, 1987.6f));
133 start.set_visible(true);
134 start.set_type(gfx::SelectionBound::CENTER);
135 gfx::SelectionBound end;
136 end.SetEdge(gfx::PointF(1337.5f, 52124.f), gfx::PointF(1234.3f, 8765.6f));
137 end.set_visible(false);
138 end.set_type(gfx::SelectionBound::RIGHT);
139 const bool is_editable = true;
140 const bool is_empty_text_form_control = true;
141 Selection<gfx::SelectionBound> input;
142 input.start = start;
143 input.end = end;
144 input.is_editable = is_editable;
145 input.is_empty_text_form_control = is_empty_text_form_control;
146 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
147 Selection<gfx::SelectionBound> output;
148 proxy->EchoSelection(input, &output);
149 EXPECT_EQ(start, output.start);
150 EXPECT_EQ(end, output.end);
151 EXPECT_EQ(is_editable, output.is_editable);
152 EXPECT_EQ(is_empty_text_form_control, output.is_empty_text_form_control);
153 }
154
124 TEST_F(StructTraitsTest, SurfaceId) { 155 TEST_F(StructTraitsTest, SurfaceId) {
125 const uint32_t id_namespace = 1337; 156 const uint32_t id_namespace = 1337;
126 const uint32_t local_id = 0xfbadbeef; 157 const uint32_t local_id = 0xfbadbeef;
127 const uint64_t nonce = 0xdeadbeef; 158 const uint64_t nonce = 0xdeadbeef;
128 SurfaceId input(id_namespace, local_id, nonce); 159 SurfaceId input(id_namespace, local_id, nonce);
129 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); 160 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
130 SurfaceId output; 161 SurfaceId output;
131 proxy->EchoSurfaceId(input, &output); 162 proxy->EchoSurfaceId(input, &output);
132 EXPECT_EQ(id_namespace, output.id_namespace()); 163 EXPECT_EQ(id_namespace, output.id_namespace());
133 EXPECT_EQ(local_id, output.local_id()); 164 EXPECT_EQ(local_id, output.local_id());
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 EXPECT_EQ(mailbox_holder.sync_token, output.mailbox_holder.sync_token); 240 EXPECT_EQ(mailbox_holder.sync_token, output.mailbox_holder.sync_token);
210 EXPECT_EQ(mailbox_holder.texture_target, 241 EXPECT_EQ(mailbox_holder.texture_target,
211 output.mailbox_holder.texture_target); 242 output.mailbox_holder.texture_target);
212 EXPECT_EQ(read_lock_fences_enabled, output.read_lock_fences_enabled); 243 EXPECT_EQ(read_lock_fences_enabled, output.read_lock_fences_enabled);
213 EXPECT_EQ(is_software, output.is_software); 244 EXPECT_EQ(is_software, output.is_software);
214 EXPECT_EQ(gpu_memory_buffer_id, output.gpu_memory_buffer_id.id); 245 EXPECT_EQ(gpu_memory_buffer_id, output.gpu_memory_buffer_id.id);
215 EXPECT_EQ(is_overlay_candidate, output.is_overlay_candidate); 246 EXPECT_EQ(is_overlay_candidate, output.is_overlay_candidate);
216 } 247 }
217 248
218 } // namespace cc 249 } // namespace cc
OLDNEW
« no previous file with comments | « cc/ipc/selection_struct_traits.h ('k') | cc/ipc/traits_test_service.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698