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

Side by Side Diff: mojo/converters/surfaces/tests/surface_unittest.cc

Issue 1496103002: Reusing base::IdType<...> to implement SurfaceId. Base URL: https://chromium.googlesource.com/chromium/src.git@type-safe-id-base
Patch Set: Rebasing + dusting off... Created 4 years, 10 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 | « mojo/converters/surfaces/surfaces_type_converters.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <utility> 8 #include <utility>
9 9
10 #include "cc/quads/debug_border_draw_quad.h" 10 #include "cc/quads/debug_border_draw_quad.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 namespace mojo { 67 namespace mojo {
68 namespace { 68 namespace {
69 69
70 TEST(SurfaceLibTest, SurfaceIdConverterNullId) { 70 TEST(SurfaceLibTest, SurfaceIdConverterNullId) {
71 cc::SurfaceId null_id; 71 cc::SurfaceId null_id;
72 cc::SurfaceId round_trip = SurfaceId::From(null_id).To<cc::SurfaceId>(); 72 cc::SurfaceId round_trip = SurfaceId::From(null_id).To<cc::SurfaceId>();
73 EXPECT_TRUE(round_trip.is_null()); 73 EXPECT_TRUE(round_trip.is_null());
74 } 74 }
75 75
76 TEST(SurfaceLibTest, SurfaceIdConverterValidId) { 76 TEST(SurfaceLibTest, SurfaceIdConverterValidId) {
77 cc::SurfaceId valid_id(7); 77 cc::SurfaceId valid_id = cc::SurfaceId::FromUnsafeValue(7);
78 cc::SurfaceId round_trip = SurfaceId::From(valid_id).To<cc::SurfaceId>(); 78 cc::SurfaceId round_trip = SurfaceId::From(valid_id).To<cc::SurfaceId>();
79 EXPECT_FALSE(round_trip.is_null()); 79 EXPECT_FALSE(round_trip.is_null());
80 EXPECT_EQ(valid_id, round_trip); 80 EXPECT_EQ(valid_id, round_trip);
81 } 81 }
82 82
83 TEST(SurfaceLibTest, Color) { 83 TEST(SurfaceLibTest, Color) {
84 SkColor arbitrary_color = SK_ColorMAGENTA; 84 SkColor arbitrary_color = SK_ColorMAGENTA;
85 SkColor round_trip = Color::From(arbitrary_color).To<SkColor>(); 85 SkColor round_trip = Color::From(arbitrary_color).To<SkColor>();
86 EXPECT_EQ(arbitrary_color, round_trip); 86 EXPECT_EQ(arbitrary_color, round_trip);
87 } 87 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 EXPECT_EQ(needs_blending, mus_quad->needs_blending); 128 EXPECT_EQ(needs_blending, mus_quad->needs_blending);
129 ASSERT_TRUE(mus_quad->solid_color_quad_state); 129 ASSERT_TRUE(mus_quad->solid_color_quad_state);
130 SolidColorQuadStatePtr& mus_color_state = mus_quad->solid_color_quad_state; 130 SolidColorQuadStatePtr& mus_color_state = mus_quad->solid_color_quad_state;
131 EXPECT_TRUE(Color::From(arbitrary_color).Equals(mus_color_state->color)); 131 EXPECT_TRUE(Color::From(arbitrary_color).Equals(mus_color_state->color));
132 EXPECT_EQ(force_anti_aliasing_off, mus_color_state->force_anti_aliasing_off); 132 EXPECT_EQ(force_anti_aliasing_off, mus_color_state->force_anti_aliasing_off);
133 } 133 }
134 134
135 TEST_F(SurfaceLibQuadTest, SurfaceQuad) { 135 TEST_F(SurfaceLibQuadTest, SurfaceQuad) {
136 cc::SurfaceDrawQuad* surface_quad = 136 cc::SurfaceDrawQuad* surface_quad =
137 pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); 137 pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>();
138 cc::SurfaceId arbitrary_id(5); 138 cc::SurfaceId arbitrary_id = cc::SurfaceId::FromUnsafeValue(5);
139 surface_quad->SetAll( 139 surface_quad->SetAll(
140 sqs, rect, opaque_rect, visible_rect, needs_blending, arbitrary_id); 140 sqs, rect, opaque_rect, visible_rect, needs_blending, arbitrary_id);
141 141
142 QuadPtr mus_quad = Quad::From<cc::DrawQuad>(*surface_quad); 142 QuadPtr mus_quad = Quad::From<cc::DrawQuad>(*surface_quad);
143 ASSERT_FALSE(mus_quad.is_null()); 143 ASSERT_FALSE(mus_quad.is_null());
144 EXPECT_EQ(mus::mojom::Material::SURFACE_CONTENT, mus_quad->material); 144 EXPECT_EQ(mus::mojom::Material::SURFACE_CONTENT, mus_quad->material);
145 ASSERT_TRUE(mus_quad->surface_quad_state); 145 ASSERT_TRUE(mus_quad->surface_quad_state);
146 SurfaceQuadStatePtr& mus_surface_state = mus_quad->surface_quad_state; 146 SurfaceQuadStatePtr& mus_surface_state = mus_quad->surface_quad_state;
147 EXPECT_TRUE(SurfaceId::From(arbitrary_id).Equals(mus_surface_state->surface)); 147 EXPECT_TRUE(SurfaceId::From(arbitrary_id).Equals(mus_surface_state->surface));
148 } 148 }
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 color_quad->SetAll(pass->shared_quad_state_list.back(), 287 color_quad->SetAll(pass->shared_quad_state_list.back(),
288 rect, 288 rect,
289 opaque_rect, 289 opaque_rect,
290 visible_rect, 290 visible_rect,
291 needs_blending, 291 needs_blending,
292 arbitrary_color, 292 arbitrary_color,
293 force_anti_aliasing_off); 293 force_anti_aliasing_off);
294 294
295 cc::SurfaceDrawQuad* surface_quad = 295 cc::SurfaceDrawQuad* surface_quad =
296 pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); 296 pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>();
297 cc::SurfaceId arbitrary_id(5); 297 cc::SurfaceId arbitrary_id = cc::SurfaceId::FromUnsafeValue(5);
298 surface_quad->SetAll( 298 surface_quad->SetAll(
299 sqs, rect, opaque_rect, visible_rect, needs_blending, arbitrary_id); 299 sqs, rect, opaque_rect, visible_rect, needs_blending, arbitrary_id);
300 300
301 cc::TextureDrawQuad* texture_quad = 301 cc::TextureDrawQuad* texture_quad =
302 pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>(); 302 pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>();
303 unsigned resource_id = 9; 303 unsigned resource_id = 9;
304 bool premultiplied_alpha = true; 304 bool premultiplied_alpha = true;
305 gfx::PointF uv_top_left(1.7f, 2.1f); 305 gfx::PointF uv_top_left(1.7f, 2.1f);
306 gfx::PointF uv_bottom_right(-7.f, 16.3f); 306 gfx::PointF uv_bottom_right(-7.f, 16.3f);
307 SkColor background_color = SK_ColorYELLOW; 307 SkColor background_color = SK_ColorYELLOW;
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 ASSERT_TRUE(mus_quad->debug_border_quad_state); 509 ASSERT_TRUE(mus_quad->debug_border_quad_state);
510 DebugBorderQuadStatePtr& mus_debug_border_state = 510 DebugBorderQuadStatePtr& mus_debug_border_state =
511 mus_quad->debug_border_quad_state; 511 mus_quad->debug_border_quad_state;
512 EXPECT_TRUE( 512 EXPECT_TRUE(
513 Color::From(arbitrary_color).Equals(mus_debug_border_state->color)); 513 Color::From(arbitrary_color).Equals(mus_debug_border_state->color));
514 EXPECT_EQ(width, mus_debug_border_state->width); 514 EXPECT_EQ(width, mus_debug_border_state->width);
515 } 515 }
516 516
517 } // namespace 517 } // namespace
518 } // namespace mojo 518 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/converters/surfaces/surfaces_type_converters.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698