Index: cc/layers/scrollbar_layer_unittest.cc |
diff --git a/cc/layers/scrollbar_layer_unittest.cc b/cc/layers/scrollbar_layer_unittest.cc |
index e7d2283c256f317a296a8ead349a0593b1f7ac90..a2cff66a496f3bb94c9c8c9120a4b2d352b3ead8 100644 |
--- a/cc/layers/scrollbar_layer_unittest.cc |
+++ b/cc/layers/scrollbar_layer_unittest.cc |
@@ -31,12 +31,11 @@ namespace { |
scoped_ptr<LayerImpl> LayerImplForScrollAreaAndScrollbar( |
FakeLayerTreeHostImpl* host_impl, |
scoped_ptr<Scrollbar> scrollbar, |
- bool reverse_order) { |
+ bool reverse_order, bool is_solid_color = false) { |
aelias_OOO_until_Jul13
2013/06/21 23:34:35
Default params aren't allowed by the style guide.
wjmaclean
2013/06/24 14:06:41
Removed.
|
scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
scoped_refptr<Layer> child1 = Layer::Create(); |
scoped_refptr<Layer> child2 = |
- ScrollbarLayer::Create(scrollbar.Pass(), |
- child1->id()); |
+ ScrollbarLayer::Create(scrollbar.Pass(), child1->id(), is_solid_color); |
layer_tree_root->AddChild(child1); |
layer_tree_root->InsertChild(child2, reverse_order ? 0 : 1); |
scoped_ptr<LayerImpl> layer_impl = |
@@ -119,8 +118,7 @@ TEST(ScrollbarLayerTest, ScrollOffsetSynchronization) { |
scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
scoped_refptr<Layer> content_layer = Layer::Create(); |
scoped_refptr<Layer> scrollbar_layer = |
- ScrollbarLayer::Create(scrollbar.Pass(), |
- layer_tree_root->id()); |
+ ScrollbarLayer::Create(scrollbar.Pass(), layer_tree_root->id(), false); |
layer_tree_root->AddChild(content_layer); |
layer_tree_root->AddChild(scrollbar_layer); |
@@ -171,18 +169,32 @@ TEST(ScrollbarLayerTest, ScrollOffsetSynchronization) { |
EXPECT_EQ(300, cc_scrollbar_layer->Maximum()); |
} |
-TEST(ScrollbarLayerTest, SolidColorDrawQuads) { |
+class SolidScrollbarLayerQuadTest |
+ : public ::testing::TestWithParam<bool> { |
+ public: |
+ SolidScrollbarLayerQuadTest() { |
+ layer_tree_settings.force_solid_color_scrollbars = GetParam(); |
+ layer_tree_settings.solid_color_scrollbar_thickness_dip = 3; |
+ |
+ host_impl = |
+ make_scoped_ptr(new FakeLayerTreeHostImpl(layer_tree_settings, &proxy)); |
+ scrollbar = make_scoped_ptr(new FakeScrollbar(false, true, true)); |
+ layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( |
+ host_impl.get(), scrollbar.Pass(), false, !GetParam()); |
+ scrollbar_layer_impl = |
+ static_cast<ScrollbarLayerImpl*>(layer_impl_tree_root->children()[1]); |
+ } |
+ |
+ protected: |
LayerTreeSettings layer_tree_settings; |
- layer_tree_settings.solid_color_scrollbars = true; |
- layer_tree_settings.solid_color_scrollbar_thickness_dip = 3; |
FakeImplProxy proxy; |
- FakeLayerTreeHostImpl host_impl(layer_tree_settings, &proxy); |
+ scoped_ptr<FakeLayerTreeHostImpl> host_impl; |
+ scoped_ptr<Scrollbar> scrollbar; |
+ scoped_ptr<LayerImpl> layer_impl_tree_root; |
+ ScrollbarLayerImpl* scrollbar_layer_impl; |
+}; |
- scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); |
- scoped_ptr<LayerImpl> layer_impl_tree_root = |
- LayerImplForScrollAreaAndScrollbar(&host_impl, scrollbar.Pass(), false); |
- ScrollbarLayerImpl* scrollbar_layer_impl = |
- static_cast<ScrollbarLayerImpl*>(layer_impl_tree_root->children()[1]); |
+TEST_P(SolidScrollbarLayerQuadTest, DrawQuads) { |
scrollbar_layer_impl->set_thumb_thickness(3); |
scrollbar_layer_impl->SetCurrentPos(10.f); |
scrollbar_layer_impl->SetMaximum(100); |
@@ -232,19 +244,7 @@ TEST(ScrollbarLayerTest, SolidColorDrawQuads) { |
} |
} |
-TEST(ScrollbarLayerTest, LayerDrivenSolidColorDrawQuads) { |
- LayerTreeSettings layer_tree_settings; |
- layer_tree_settings.solid_color_scrollbars = true; |
- layer_tree_settings.solid_color_scrollbar_thickness_dip = 3; |
- FakeImplProxy proxy; |
- FakeLayerTreeHostImpl host_impl(layer_tree_settings, &proxy); |
- |
- scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); |
- scoped_ptr<LayerImpl> layer_impl_tree_root = |
- LayerImplForScrollAreaAndScrollbar(&host_impl, scrollbar.Pass(), false); |
- ScrollbarLayerImpl* scrollbar_layer_impl = |
- static_cast<ScrollbarLayerImpl*>(layer_impl_tree_root->children()[1]); |
- |
+TEST_P(SolidScrollbarLayerQuadTest, LayerDrivenSolidColorDrawQuads) { |
scrollbar_layer_impl->set_thumb_thickness(3); |
scrollbar_layer_impl->set_track_length(10); |
scrollbar_layer_impl->SetCurrentPos(4.f); |
@@ -267,17 +267,21 @@ TEST(ScrollbarLayerTest, LayerDrivenSolidColorDrawQuads) { |
} |
} |
-class ScrollbarLayerSolidColorThumbTest : public testing::Test { |
+INSTANTIATE_TEST_CASE_P(ParameterizedSolidColorScrollbarTest, |
+ SolidScrollbarLayerQuadTest, |
+ ::testing::Values(true, false)); |
+ |
+class ScrollbarLayerSolidColorThumbTest : public testing::TestWithParam<bool> { |
public: |
ScrollbarLayerSolidColorThumbTest() { |
LayerTreeSettings layer_tree_settings; |
- layer_tree_settings.solid_color_scrollbars = true; |
+ layer_tree_settings.force_solid_color_scrollbars = GetParam(); |
host_impl_.reset(new FakeLayerTreeHostImpl(layer_tree_settings, &proxy_)); |
horizontal_scrollbar_layer_ = ScrollbarLayerImpl::Create( |
- host_impl_->active_tree(), 1, HORIZONTAL); |
+ host_impl_->active_tree(), 1, HORIZONTAL, !GetParam()); |
vertical_scrollbar_layer_ = ScrollbarLayerImpl::Create( |
- host_impl_->active_tree(), 2, VERTICAL); |
+ host_impl_->active_tree(), 2, VERTICAL, !GetParam()); |
} |
protected: |
@@ -287,7 +291,7 @@ class ScrollbarLayerSolidColorThumbTest : public testing::Test { |
scoped_ptr<ScrollbarLayerImpl> vertical_scrollbar_layer_; |
}; |
-TEST_F(ScrollbarLayerSolidColorThumbTest, SolidColorThumbLength) { |
+TEST_P(ScrollbarLayerSolidColorThumbTest, SolidColorThumbLength) { |
horizontal_scrollbar_layer_->SetCurrentPos(0); |
horizontal_scrollbar_layer_->SetMaximum(10); |
horizontal_scrollbar_layer_->set_thumb_thickness(3); |
@@ -304,7 +308,7 @@ TEST_F(ScrollbarLayerSolidColorThumbTest, SolidColorThumbLength) { |
EXPECT_EQ(3, horizontal_scrollbar_layer_->ComputeThumbQuadRect().width()); |
} |
-TEST_F(ScrollbarLayerSolidColorThumbTest, SolidColorThumbPosition) { |
+TEST_P(ScrollbarLayerSolidColorThumbTest, SolidColorThumbPosition) { |
horizontal_scrollbar_layer_->set_track_length(100); |
horizontal_scrollbar_layer_->set_visible_to_total_length_ratio(0.1f); |
horizontal_scrollbar_layer_->set_thumb_thickness(3); |
@@ -325,7 +329,7 @@ TEST_F(ScrollbarLayerSolidColorThumbTest, SolidColorThumbPosition) { |
EXPECT_EQ(72, horizontal_scrollbar_layer_->ComputeThumbQuadRect().x()); |
} |
-TEST_F(ScrollbarLayerSolidColorThumbTest, SolidColorThumbVerticalAdjust) { |
+TEST_P(ScrollbarLayerSolidColorThumbTest, SolidColorThumbVerticalAdjust) { |
ScrollbarLayerImpl* layers[2] = |
{ horizontal_scrollbar_layer_.get(), vertical_scrollbar_layer_.get() }; |
for (size_t i = 0; i < 2; ++i) { |
@@ -354,6 +358,10 @@ TEST_F(ScrollbarLayerSolidColorThumbTest, SolidColorThumbVerticalAdjust) { |
vertical_scrollbar_layer_->ComputeThumbQuadRect()); |
} |
+INSTANTIATE_TEST_CASE_P(ParameterizedSolidColorThumbTest, |
+ ScrollbarLayerSolidColorThumbTest, |
+ ::testing::Values(true, false)); |
+ |
class ScrollbarLayerTestMaxTextureSize : public LayerTreeTest { |
public: |
ScrollbarLayerTestMaxTextureSize() {} |
@@ -362,7 +370,7 @@ class ScrollbarLayerTestMaxTextureSize : public LayerTreeTest { |
virtual void BeginTest() OVERRIDE { |
scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); |
- scrollbar_layer_ = ScrollbarLayer::Create(scrollbar.Pass(), 1); |
+ scrollbar_layer_ = ScrollbarLayer::Create(scrollbar.Pass(), 1, false); |
scrollbar_layer_->SetLayerTreeHost(layer_tree_host()); |
scrollbar_layer_->SetBounds(bounds_); |
layer_tree_host()->root_layer()->AddChild(scrollbar_layer_); |
@@ -438,7 +446,7 @@ class ScrollbarLayerTestResourceCreation : public testing::Test { |
scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
scoped_refptr<Layer> content_layer = Layer::Create(); |
scoped_refptr<Layer> scrollbar_layer = |
- ScrollbarLayer::Create(scrollbar.Pass(), layer_tree_root->id()); |
+ ScrollbarLayer::Create(scrollbar.Pass(), layer_tree_root->id(), false); |
layer_tree_root->AddChild(content_layer); |
layer_tree_root->AddChild(scrollbar_layer); |
@@ -482,12 +490,12 @@ class ScrollbarLayerTestResourceCreation : public testing::Test { |
}; |
TEST_F(ScrollbarLayerTestResourceCreation, ResourceUpload) { |
- layer_tree_settings_.solid_color_scrollbars = false; |
+ layer_tree_settings_.force_solid_color_scrollbars = false; |
TestResourceUpload(2); |
} |
TEST_F(ScrollbarLayerTestResourceCreation, SolidColorNoResourceUpload) { |
- layer_tree_settings_.solid_color_scrollbars = true; |
+ layer_tree_settings_.force_solid_color_scrollbars = true; |
TestResourceUpload(0); |
} |
@@ -506,9 +514,8 @@ class ScaledScrollbarLayerTestResourceCreation : public testing::Test { |
scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
scoped_refptr<Layer> content_layer = Layer::Create(); |
- scoped_refptr<Layer> scrollbar_layer = |
- ScrollbarLayer::Create(scrollbar.PassAs<cc::Scrollbar>(), |
- layer_tree_root->id()); |
+ scoped_refptr<Layer> scrollbar_layer = ScrollbarLayer::Create( |
+ scrollbar.PassAs<cc::Scrollbar>(), layer_tree_root->id(), false); |
layer_tree_root->AddChild(content_layer); |
layer_tree_root->AddChild(scrollbar_layer); |
@@ -575,7 +582,7 @@ class ScaledScrollbarLayerTestResourceCreation : public testing::Test { |
}; |
TEST_F(ScaledScrollbarLayerTestResourceCreation, ScaledResourceUpload) { |
- layer_tree_settings_.solid_color_scrollbars = false; |
+ layer_tree_settings_.force_solid_color_scrollbars = false; |
// Pick a test scale that moves the scrollbar's (non-zero) position to |
// a non-pixel-aligned location. |
TestResourceUpload(2, 1.41f); |