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

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

Issue 1143433005: Remove gfx::FrameTime for a single clock source (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Handling patch for mac files Created 5 years, 7 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
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_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 #include "cc/test/test_shared_bitmap_manager.h" 58 #include "cc/test/test_shared_bitmap_manager.h"
59 #include "cc/test/test_task_graph_runner.h" 59 #include "cc/test/test_task_graph_runner.h"
60 #include "cc/test/test_web_graphics_context_3d.h" 60 #include "cc/test/test_web_graphics_context_3d.h"
61 #include "cc/tiles/layer_tiling_data.h" 61 #include "cc/tiles/layer_tiling_data.h"
62 #include "cc/trees/layer_tree_impl.h" 62 #include "cc/trees/layer_tree_impl.h"
63 #include "cc/trees/single_thread_proxy.h" 63 #include "cc/trees/single_thread_proxy.h"
64 #include "media/base/media.h" 64 #include "media/base/media.h"
65 #include "testing/gmock/include/gmock/gmock.h" 65 #include "testing/gmock/include/gmock/gmock.h"
66 #include "testing/gtest/include/gtest/gtest.h" 66 #include "testing/gtest/include/gtest/gtest.h"
67 #include "third_party/skia/include/core/SkMallocPixelRef.h" 67 #include "third_party/skia/include/core/SkMallocPixelRef.h"
68 #include "ui/gfx/frame_time.h"
69 #include "ui/gfx/geometry/rect_conversions.h" 68 #include "ui/gfx/geometry/rect_conversions.h"
70 #include "ui/gfx/geometry/size_conversions.h" 69 #include "ui/gfx/geometry/size_conversions.h"
71 #include "ui/gfx/geometry/vector2d_conversions.h" 70 #include "ui/gfx/geometry/vector2d_conversions.h"
72 71
73 using ::testing::Mock; 72 using ::testing::Mock;
74 using ::testing::Return; 73 using ::testing::Return;
75 using ::testing::AnyNumber; 74 using ::testing::AnyNumber;
76 using ::testing::AtLeast; 75 using ::testing::AtLeast;
77 using ::testing::_; 76 using ::testing::_;
78 using media::VideoFrame; 77 using media::VideoFrame;
(...skipping 1632 matching lines...) Expand 10 before | Expand all | Expand 10 after
1711 } 1710 }
1712 1711
1713 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { 1712 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) {
1714 LayerTreeSettings settings; 1713 LayerTreeSettings settings;
1715 settings.scrollbar_animator = animator; 1714 settings.scrollbar_animator = animator;
1716 settings.scrollbar_fade_delay_ms = 20; 1715 settings.scrollbar_fade_delay_ms = 20;
1717 settings.scrollbar_fade_duration_ms = 20; 1716 settings.scrollbar_fade_duration_ms = 20;
1718 1717
1719 SetupLayers(settings); 1718 SetupLayers(settings);
1720 1719
1721 base::TimeTicks fake_now = gfx::FrameTime::Now(); 1720 base::TimeTicks fake_now = base::TimeTicks::Now();
1722 1721
1723 EXPECT_FALSE(did_request_animate_); 1722 EXPECT_FALSE(did_request_animate_);
1724 EXPECT_FALSE(did_request_redraw_); 1723 EXPECT_FALSE(did_request_redraw_);
1725 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); 1724 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_);
1726 EXPECT_TRUE(animation_task_.Equals(base::Closure())); 1725 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
1727 1726
1728 // If no scroll happened during a scroll gesture, it should have no effect. 1727 // If no scroll happened during a scroll gesture, it should have no effect.
1729 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL); 1728 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL);
1730 host_impl_->ScrollEnd(); 1729 host_impl_->ScrollEnd();
1731 EXPECT_FALSE(did_request_animate_); 1730 EXPECT_FALSE(did_request_animate_);
(...skipping 5166 matching lines...) Expand 10 before | Expand all | Expand 10 after
6898 6897
6899 // End the scroll while the controls are still offset from their limit. 6898 // End the scroll while the controls are still offset from their limit.
6900 host_impl_->ScrollEnd(); 6899 host_impl_->ScrollEnd();
6901 ASSERT_TRUE(host_impl_->top_controls_manager()->animation()); 6900 ASSERT_TRUE(host_impl_->top_controls_manager()->animation());
6902 EXPECT_TRUE(did_request_animate_); 6901 EXPECT_TRUE(did_request_animate_);
6903 EXPECT_TRUE(did_request_redraw_); 6902 EXPECT_TRUE(did_request_redraw_);
6904 EXPECT_FALSE(did_request_commit_); 6903 EXPECT_FALSE(did_request_commit_);
6905 6904
6906 // The top controls should properly animate until finished, despite the scroll 6905 // The top controls should properly animate until finished, despite the scroll
6907 // offset being at the origin. 6906 // offset being at the origin.
6908 base::TimeTicks animation_time = gfx::FrameTime::Now(); 6907 base::TimeTicks animation_time = base::TimeTicks::Now();
6909 while (did_request_animate_) { 6908 while (did_request_animate_) {
6910 did_request_redraw_ = false; 6909 did_request_redraw_ = false;
6911 did_request_animate_ = false; 6910 did_request_animate_ = false;
6912 did_request_commit_ = false; 6911 did_request_commit_ = false;
6913 6912
6914 float old_offset = 6913 float old_offset =
6915 host_impl_->top_controls_manager()->ControlsTopOffset(); 6914 host_impl_->top_controls_manager()->ControlsTopOffset();
6916 6915
6917 animation_time += base::TimeDelta::FromMilliseconds(5); 6916 animation_time += base::TimeDelta::FromMilliseconds(5);
6918 host_impl_->Animate(animation_time); 6917 host_impl_->Animate(animation_time);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
6968 did_request_commit_ = false; 6967 did_request_commit_ = false;
6969 6968
6970 // End the scroll while the controls are still offset from the limit. 6969 // End the scroll while the controls are still offset from the limit.
6971 host_impl_->ScrollEnd(); 6970 host_impl_->ScrollEnd();
6972 ASSERT_TRUE(host_impl_->top_controls_manager()->animation()); 6971 ASSERT_TRUE(host_impl_->top_controls_manager()->animation());
6973 EXPECT_TRUE(did_request_animate_); 6972 EXPECT_TRUE(did_request_animate_);
6974 EXPECT_TRUE(did_request_redraw_); 6973 EXPECT_TRUE(did_request_redraw_);
6975 EXPECT_FALSE(did_request_commit_); 6974 EXPECT_FALSE(did_request_commit_);
6976 6975
6977 // Animate the top controls to the limit. 6976 // Animate the top controls to the limit.
6978 base::TimeTicks animation_time = gfx::FrameTime::Now(); 6977 base::TimeTicks animation_time = base::TimeTicks::Now();
6979 while (did_request_animate_) { 6978 while (did_request_animate_) {
6980 did_request_redraw_ = false; 6979 did_request_redraw_ = false;
6981 did_request_animate_ = false; 6980 did_request_animate_ = false;
6982 did_request_commit_ = false; 6981 did_request_commit_ = false;
6983 6982
6984 float old_offset = 6983 float old_offset =
6985 host_impl_->top_controls_manager()->ControlsTopOffset(); 6984 host_impl_->top_controls_manager()->ControlsTopOffset();
6986 6985
6987 animation_time += base::TimeDelta::FromMilliseconds(5); 6986 animation_time += base::TimeDelta::FromMilliseconds(5);
6988 host_impl_->Animate(animation_time); 6987 host_impl_->Animate(animation_time);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
7032 did_request_commit_ = false; 7031 did_request_commit_ = false;
7033 7032
7034 // End the fling while the controls are still offset from the limit. 7033 // End the fling while the controls are still offset from the limit.
7035 host_impl_->MainThreadHasStoppedFlinging(); 7034 host_impl_->MainThreadHasStoppedFlinging();
7036 ASSERT_TRUE(host_impl_->top_controls_manager()->animation()); 7035 ASSERT_TRUE(host_impl_->top_controls_manager()->animation());
7037 EXPECT_TRUE(did_request_animate_); 7036 EXPECT_TRUE(did_request_animate_);
7038 EXPECT_TRUE(did_request_redraw_); 7037 EXPECT_TRUE(did_request_redraw_);
7039 EXPECT_FALSE(did_request_commit_); 7038 EXPECT_FALSE(did_request_commit_);
7040 7039
7041 // Animate the top controls to the limit. 7040 // Animate the top controls to the limit.
7042 base::TimeTicks animation_time = gfx::FrameTime::Now(); 7041 base::TimeTicks animation_time = base::TimeTicks::Now();
7043 while (did_request_animate_) { 7042 while (did_request_animate_) {
7044 did_request_redraw_ = false; 7043 did_request_redraw_ = false;
7045 did_request_animate_ = false; 7044 did_request_animate_ = false;
7046 did_request_commit_ = false; 7045 did_request_commit_ = false;
7047 7046
7048 float old_offset = host_impl_->top_controls_manager()->ControlsTopOffset(); 7047 float old_offset = host_impl_->top_controls_manager()->ControlsTopOffset();
7049 7048
7050 animation_time += base::TimeDelta::FromMilliseconds(5); 7049 animation_time += base::TimeDelta::FromMilliseconds(5);
7051 host_impl_->Animate(animation_time); 7050 host_impl_->Animate(animation_time);
7052 7051
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after
7873 // Hold an unowned pointer to the output surface to use for mock expectations. 7872 // Hold an unowned pointer to the output surface to use for mock expectations.
7874 MockReclaimResourcesOutputSurface* mock_output_surface = output_surface.get(); 7873 MockReclaimResourcesOutputSurface* mock_output_surface = output_surface.get();
7875 7874
7876 CreateHostImpl(DefaultSettings(), output_surface.Pass()); 7875 CreateHostImpl(DefaultSettings(), output_surface.Pass());
7877 EXPECT_CALL(*mock_output_surface, ForceReclaimResources()).Times(1); 7876 EXPECT_CALL(*mock_output_surface, ForceReclaimResources()).Times(1);
7878 host_impl_->BeginCommit(); 7877 host_impl_->BeginCommit();
7879 } 7878 }
7880 7879
7881 } // namespace 7880 } // namespace
7882 } // namespace cc 7881 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698