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

Side by Side Diff: cc/trees/layer_tree_host_unittest.cc

Issue 774763004: Use EXPECT_EQ when possible. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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/trees/layer_tree_host_impl_unittest.cc ('k') | cc/trees/layer_tree_impl_unittest.cc » ('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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 "cc/trees/layer_tree_host.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 LayerTreeHostImpl::FrameData* frame_data, 437 LayerTreeHostImpl::FrameData* frame_data,
438 DrawResult draw_result) override { 438 DrawResult draw_result) override {
439 EXPECT_EQ(DRAW_SUCCESS, draw_result); 439 EXPECT_EQ(DRAW_SUCCESS, draw_result);
440 440
441 gfx::RectF root_damage_rect; 441 gfx::RectF root_damage_rect;
442 if (!frame_data->render_passes.empty()) 442 if (!frame_data->render_passes.empty())
443 root_damage_rect = frame_data->render_passes.back()->damage_rect; 443 root_damage_rect = frame_data->render_passes.back()->damage_rect;
444 444
445 if (!num_draws_) { 445 if (!num_draws_) {
446 // If this is the first frame, expect full frame damage. 446 // If this is the first frame, expect full frame damage.
447 EXPECT_RECT_EQ(root_damage_rect, gfx::Rect(bounds_)); 447 EXPECT_EQ(root_damage_rect, gfx::Rect(bounds_));
448 } else { 448 } else {
449 // Check that invalid_rect_ is indeed repainted. 449 // Check that invalid_rect_ is indeed repainted.
450 EXPECT_TRUE(root_damage_rect.Contains(invalid_rect_)); 450 EXPECT_TRUE(root_damage_rect.Contains(invalid_rect_));
451 } 451 }
452 452
453 return draw_result; 453 return draw_result;
454 } 454 }
455 455
456 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { 456 void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
457 if (!num_draws_) { 457 if (!num_draws_) {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 LayerTreeHostImpl::FrameData* frame_data, 619 LayerTreeHostImpl::FrameData* frame_data,
620 DrawResult draw_result) override { 620 DrawResult draw_result) override {
621 EXPECT_EQ(DRAW_SUCCESS, draw_result); 621 EXPECT_EQ(DRAW_SUCCESS, draw_result);
622 622
623 gfx::RectF root_damage_rect; 623 gfx::RectF root_damage_rect;
624 if (!frame_data->render_passes.empty()) 624 if (!frame_data->render_passes.empty())
625 root_damage_rect = frame_data->render_passes.back()->damage_rect; 625 root_damage_rect = frame_data->render_passes.back()->damage_rect;
626 626
627 switch (num_draws_) { 627 switch (num_draws_) {
628 case 0: 628 case 0:
629 EXPECT_RECT_EQ(gfx::Rect(bounds_), root_damage_rect); 629 EXPECT_EQ(gfx::Rect(bounds_), root_damage_rect);
630 break; 630 break;
631 case 1: 631 case 1:
632 case 2: 632 case 2:
633 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), root_damage_rect); 633 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root_damage_rect);
634 break; 634 break;
635 case 3: 635 case 3:
636 EXPECT_RECT_EQ(invalid_rect_, root_damage_rect); 636 EXPECT_EQ(invalid_rect_, root_damage_rect);
637 break; 637 break;
638 case 4: 638 case 4:
639 EXPECT_RECT_EQ(gfx::Rect(bounds_), root_damage_rect); 639 EXPECT_EQ(gfx::Rect(bounds_), root_damage_rect);
640 break; 640 break;
641 default: 641 default:
642 NOTREACHED(); 642 NOTREACHED();
643 } 643 }
644 644
645 return draw_result; 645 return draw_result;
646 } 646 }
647 647
648 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { 648 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override {
649 switch (num_draws_) { 649 switch (num_draws_) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 if (!frame_data->render_passes.empty()) 731 if (!frame_data->render_passes.empty())
732 root_damage_rect = frame_data->render_passes.back()->damage_rect; 732 root_damage_rect = frame_data->render_passes.back()->damage_rect;
733 733
734 // The first time, the whole view needs be drawn. 734 // The first time, the whole view needs be drawn.
735 // Afterwards, just the opacity of surface_layer1 is changed a few times, 735 // Afterwards, just the opacity of surface_layer1 is changed a few times,
736 // and each damage should be the bounding box of it and its child. If this 736 // and each damage should be the bounding box of it and its child. If this
737 // was working improperly, the damage might not include its childs bounding 737 // was working improperly, the damage might not include its childs bounding
738 // box. 738 // box.
739 switch (host_impl->active_tree()->source_frame_number()) { 739 switch (host_impl->active_tree()->source_frame_number()) {
740 case 0: 740 case 0:
741 EXPECT_RECT_EQ(gfx::Rect(root_layer_->bounds()), root_damage_rect); 741 EXPECT_EQ(gfx::Rect(root_layer_->bounds()), root_damage_rect);
742 break; 742 break;
743 case 1: 743 case 1:
744 case 2: 744 case 2:
745 case 3: 745 case 3:
746 EXPECT_RECT_EQ(gfx::Rect(child_layer_->bounds()), root_damage_rect); 746 EXPECT_EQ(gfx::Rect(child_layer_->bounds()), root_damage_rect);
747 break; 747 break;
748 default: 748 default:
749 NOTREACHED(); 749 NOTREACHED();
750 } 750 }
751 751
752 return draw_result; 752 return draw_result;
753 } 753 }
754 754
755 void DidCommitAndDrawFrame() override { 755 void DidCommitAndDrawFrame() override {
756 switch (layer_tree_host()->source_frame_number()) { 756 switch (layer_tree_host()->source_frame_number()) {
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
1264 const LayerImplList& render_surface_layer_list = 1264 const LayerImplList& render_surface_layer_list =
1265 *frame_data.render_surface_layer_list; 1265 *frame_data.render_surface_layer_list;
1266 1266
1267 // Both layers should be drawing into the root render surface. 1267 // Both layers should be drawing into the root render surface.
1268 ASSERT_EQ(1u, render_surface_layer_list.size()); 1268 ASSERT_EQ(1u, render_surface_layer_list.size());
1269 ASSERT_EQ(root->render_surface(), 1269 ASSERT_EQ(root->render_surface(),
1270 render_surface_layer_list[0]->render_surface()); 1270 render_surface_layer_list[0]->render_surface());
1271 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); 1271 ASSERT_EQ(2u, root->render_surface()->layer_list().size());
1272 1272
1273 // The root render surface is the size of the viewport. 1273 // The root render surface is the size of the viewport.
1274 EXPECT_RECT_EQ(gfx::Rect(0, 0, 60, 60), 1274 EXPECT_EQ(gfx::Rect(0, 0, 60, 60), root->render_surface()->content_rect());
1275 root->render_surface()->content_rect());
1276 1275
1277 // The max tiling scale of the child should be scaled. 1276 // The max tiling scale of the child should be scaled.
1278 EXPECT_FLOAT_EQ(1.5f, child->MaximumTilingContentsScale()); 1277 EXPECT_FLOAT_EQ(1.5f, child->MaximumTilingContentsScale());
1279 1278
1280 gfx::Transform scale_transform; 1279 gfx::Transform scale_transform;
1281 scale_transform.Scale(impl->device_scale_factor(), 1280 scale_transform.Scale(impl->device_scale_factor(),
1282 impl->device_scale_factor()); 1281 impl->device_scale_factor());
1283 1282
1284 // The root layer is scaled by 2x. 1283 // The root layer is scaled by 2x.
1285 gfx::Transform root_screen_space_transform = scale_transform; 1284 gfx::Transform root_screen_space_transform = scale_transform;
(...skipping 1352 matching lines...) Expand 10 before | Expand all | Expand 10 after
2638 LayerTreeHostTest::SetupTree(); 2637 LayerTreeHostTest::SetupTree();
2639 } 2638 }
2640 2639
2641 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 2640 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
2642 void AfterTest() override {} 2641 void AfterTest() override {}
2643 2642
2644 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { 2643 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
2645 num_commits_++; 2644 num_commits_++;
2646 if (num_commits_ == 1) { 2645 if (num_commits_ == 1) {
2647 LayerImpl* root_layer = host_impl->active_tree()->root_layer(); 2646 LayerImpl* root_layer = host_impl->active_tree()->root_layer();
2648 EXPECT_SIZE_EQ(gfx::Size(1, 1), root_layer->bounds()); 2647 EXPECT_EQ(gfx::Size(1, 1), root_layer->bounds());
2649 } else { 2648 } else {
2650 LayerImpl* root_layer = host_impl->active_tree()->root_layer(); 2649 LayerImpl* root_layer = host_impl->active_tree()->root_layer();
2651 EXPECT_SIZE_EQ(gfx::Size(2, 2), root_layer->bounds()); 2650 EXPECT_EQ(gfx::Size(2, 2), root_layer->bounds());
2652 EndTest(); 2651 EndTest();
2653 } 2652 }
2654 } 2653 }
2655 2654
2656 private: 2655 private:
2657 SetBoundsClient client_; 2656 SetBoundsClient client_;
2658 int num_commits_; 2657 int num_commits_;
2659 }; 2658 };
2660 2659
2661 SINGLE_AND_MULTI_THREAD_TEST_F( 2660 SINGLE_AND_MULTI_THREAD_TEST_F(
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
2764 DrawResult draw_result) override { 2763 DrawResult draw_result) override {
2765 Mock::VerifyAndClearExpectations(&mock_context_); 2764 Mock::VerifyAndClearExpectations(&mock_context_);
2766 ResourceProvider* resource_provider = host_impl->resource_provider(); 2765 ResourceProvider* resource_provider = host_impl->resource_provider();
2767 EXPECT_EQ(1u, resource_provider->num_resources()); 2766 EXPECT_EQ(1u, resource_provider->num_resources());
2768 CHECK_EQ(1u, frame->render_passes.size()); 2767 CHECK_EQ(1u, frame->render_passes.size());
2769 CHECK_LE(1u, frame->render_passes[0]->quad_list.size()); 2768 CHECK_LE(1u, frame->render_passes[0]->quad_list.size());
2770 const DrawQuad* quad = frame->render_passes[0]->quad_list.front(); 2769 const DrawQuad* quad = frame->render_passes[0]->quad_list.front();
2771 CHECK_EQ(DrawQuad::IO_SURFACE_CONTENT, quad->material); 2770 CHECK_EQ(DrawQuad::IO_SURFACE_CONTENT, quad->material);
2772 const IOSurfaceDrawQuad* io_surface_draw_quad = 2771 const IOSurfaceDrawQuad* io_surface_draw_quad =
2773 IOSurfaceDrawQuad::MaterialCast(quad); 2772 IOSurfaceDrawQuad::MaterialCast(quad);
2774 EXPECT_SIZE_EQ(io_surface_size_, io_surface_draw_quad->io_surface_size); 2773 EXPECT_EQ(io_surface_size_, io_surface_draw_quad->io_surface_size);
2775 EXPECT_NE(0u, io_surface_draw_quad->io_surface_resource_id); 2774 EXPECT_NE(0u, io_surface_draw_quad->io_surface_resource_id);
2776 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_RECTANGLE_ARB), 2775 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_RECTANGLE_ARB),
2777 resource_provider->TargetForTesting( 2776 resource_provider->TargetForTesting(
2778 io_surface_draw_quad->io_surface_resource_id)); 2777 io_surface_draw_quad->io_surface_resource_id));
2779 2778
2780 EXPECT_CALL(*mock_context_, bindTexture(GL_TEXTURE_RECTANGLE_ARB, 1)) 2779 EXPECT_CALL(*mock_context_, bindTexture(GL_TEXTURE_RECTANGLE_ARB, 1))
2781 .Times(1); 2780 .Times(1);
2782 if (delegating_renderer()) { 2781 if (delegating_renderer()) {
2783 // The io surface layer's resource should be sent to the parent. 2782 // The io surface layer's resource should be sent to the parent.
2784 EXPECT_CALL(*mock_context_, 2783 EXPECT_CALL(*mock_context_,
(...skipping 3151 matching lines...) Expand 10 before | Expand all | Expand 10 after
5936 5935
5937 protected: 5936 protected:
5938 FakeContentLayerClient client_; 5937 FakeContentLayerClient client_;
5939 size_t notify_ready_to_activate_count_; 5938 size_t notify_ready_to_activate_count_;
5940 size_t scheduled_manage_tiles_count_; 5939 size_t scheduled_manage_tiles_count_;
5941 }; 5940 };
5942 5941
5943 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestOneActivatePerManageTiles); 5942 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestOneActivatePerManageTiles);
5944 5943
5945 } // namespace cc 5944 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl_unittest.cc ('k') | cc/trees/layer_tree_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698