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

Unified Diff: cc/layer_tree_host_unittest_scroll.cc

Issue 11662003: cc: Put context-loss tests in layer_tree_host_unittest_context.cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rm macros Created 7 years, 12 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 side-by-side diff with in-line comments
Download patch
Index: cc/layer_tree_host_unittest_scroll.cc
diff --git a/cc/layer_tree_host_unittest_scroll.cc b/cc/layer_tree_host_unittest_scroll.cc
index 15ab63b17e7a391ed5c300e52b326e7fa42690c3..d3089e1c2b2f51cf281bd8c42cc6b669c185a517 100644
--- a/cc/layer_tree_host_unittest_scroll.cc
+++ b/cc/layer_tree_host_unittest_scroll.cc
@@ -237,22 +237,20 @@ TEST_F(LayerTreeHostScrollTestFractionalScroll, runMultiThread)
runTest(true);
}
+template<int kDeviceScaleFactorTimesTen, bool kScrollChildLayer>
class LayerTreeHostScrollTestCaseWithChild :
public LayerTreeHostScrollTest,
public WebKit::WebLayerScrollClient {
public:
- LayerTreeHostScrollTestCaseWithChild(
- float device_scale_factor, bool scroll_child_layer)
- : device_scale_factor_(device_scale_factor),
- scroll_child_layer_(scroll_child_layer),
- initial_offset_(10, 20),
+ LayerTreeHostScrollTestCaseWithChild()
+ : initial_offset_(10, 20),
javascript_scroll_(40, 5),
scroll_amount_(2, -1),
num_scrolls_(0) {
}
virtual void setupTree() OVERRIDE {
- m_layerTreeHost->setDeviceScaleFactor(device_scale_factor_);
+ m_layerTreeHost->setDeviceScaleFactor(kDeviceScaleFactorTimesTen / 10.f);
scoped_refptr<Layer> root_layer = Layer::create();
root_layer->setBounds(gfx::Size(10, 10));
@@ -283,7 +281,7 @@ class LayerTreeHostScrollTestCaseWithChild :
child_layer_->setMaxScrollOffset(gfx::Vector2d(100, 100));
root_scroll_layer_->addChild(child_layer_);
- if (scroll_child_layer_) {
+ if (kScrollChildLayer) {
expected_scroll_layer_ = child_layer_;
expected_no_scroll_layer_ = root_scroll_layer_;
} else {
@@ -345,7 +343,7 @@ class LayerTreeHostScrollTestCaseWithChild :
LayerImpl* expected_scroll_layer_impl = NULL;
LayerImpl* expected_no_scroll_layer_impl = NULL;
- if (scroll_child_layer_) {
+ if (kScrollChildLayer) {
expected_scroll_layer_impl = child_layer_impl;
expected_no_scroll_layer_impl = root_scroll_layer_impl;
} else {
@@ -360,13 +358,16 @@ class LayerTreeHostScrollTestCaseWithChild :
// Ensure device scale factor is affecting the layers.
gfx::Size expected_content_bounds = gfx::ToCeiledSize(
- gfx::ScaleSize(root_scroll_layer_impl->bounds(), device_scale_factor_));
+ gfx::ScaleSize(
+ root_scroll_layer_impl->bounds(),
+ kDeviceScaleFactorTimesTen / 10.f));
EXPECT_SIZE_EQ(
expected_content_bounds,
root_scroll_layer_->contentBounds());
expected_content_bounds = gfx::ToCeiledSize(
- gfx::ScaleSize(child_layer_impl->bounds(), device_scale_factor_));
+ gfx::ScaleSize(
+ child_layer_impl->bounds(), kDeviceScaleFactorTimesTen / 10.f));
EXPECT_SIZE_EQ(expected_content_bounds, child_layer_->contentBounds());
switch (impl->activeTree()->source_frame_number()) {
@@ -425,7 +426,7 @@ class LayerTreeHostScrollTestCaseWithChild :
}
virtual void afterTest() OVERRIDE {
- if (scroll_child_layer_) {
+ if (kScrollChildLayer) {
EXPECT_EQ(0, num_scrolls_);
EXPECT_VECTOR_EQ(
javascript_scroll_ + scroll_amount_,
@@ -437,8 +438,6 @@ class LayerTreeHostScrollTestCaseWithChild :
}
private:
- float device_scale_factor_;
- bool scroll_child_layer_;
gfx::Vector2d initial_offset_;
gfx::Vector2d javascript_scroll_;
gfx::Vector2d scroll_amount_;
@@ -453,24 +452,42 @@ class LayerTreeHostScrollTestCaseWithChild :
scoped_refptr<Layer> expected_no_scroll_layer_;
};
-MULTI_THREAD_TEST_P2(LayerTreeHostScrollTestCaseWithChild,
- DeviceScaleFactor1, 1.0f,
- ScrollChild, true)
-MULTI_THREAD_TEST_P2(LayerTreeHostScrollTestCaseWithChild,
- DeviceScaleFactor15, 1.5f,
- ScrollChild, true)
-MULTI_THREAD_TEST_P2(LayerTreeHostScrollTestCaseWithChild,
- DeviceScaleFactor2, 2.0f,
- ScrollChild, true)
-MULTI_THREAD_TEST_P2(LayerTreeHostScrollTestCaseWithChild,
- DeviceScaleFactor1, 1.0f,
- ScrollRootScrollLayer, false)
-MULTI_THREAD_TEST_P2(LayerTreeHostScrollTestCaseWithChild,
- DeviceScaleFactor15, 1.5f,
- ScrollRootScrollLayer, false)
-MULTI_THREAD_TEST_P2(LayerTreeHostScrollTestCaseWithChild,
- DeviceScaleFactor2, 2.0f,
- ScrollRootScrollLayer, false)
+class LayerTreeHostScrollTestScrollChild_DeviceScaleFactor1
+ : public LayerTreeHostScrollTestCaseWithChild<10, true> {};
+
+MULTI_THREAD_TEST_F(
+ LayerTreeHostScrollTestScrollChild_DeviceScaleFactor1)
jamesr 2013/01/03 22:59:07 this is 5 lines to set up and run a threaded test.
+
+class LayerTreeHostScrollTestScrollChild_DeviceScaleFactor15
+ : public LayerTreeHostScrollTestCaseWithChild<15, true> {};
+
+MULTI_THREAD_TEST_F(
+ LayerTreeHostScrollTestScrollChild_DeviceScaleFactor15)
+
+class LayerTreeHostScrollTestScrollChild_DeviceScaleFactor2
+ : public LayerTreeHostScrollTestCaseWithChild<20, true> {};
+
+MULTI_THREAD_TEST_F(
+ LayerTreeHostScrollTestScrollChild_DeviceScaleFactor2)
+
+class LayerTreeHostScrollTestScrollRootScrollLayer_DeviceScaleFactor1
+ : public LayerTreeHostScrollTestCaseWithChild<10, true> {};
+
+MULTI_THREAD_TEST_F(
+ LayerTreeHostScrollTestScrollRootScrollLayer_DeviceScaleFactor1)
+
+class LayerTreeHostScrollTestScrollRootScrollLayer_DeviceScaleFactor15
+ : public LayerTreeHostScrollTestCaseWithChild<15, true> {};
+
+MULTI_THREAD_TEST_F(
+ LayerTreeHostScrollTestScrollRootScrollLayer_DeviceScaleFactor15)
+
+class LayerTreeHostScrollTestScrollRootScrollLayer_DeviceScaleFactor2
+ : public LayerTreeHostScrollTestCaseWithChild<20, true> {};
+
+MULTI_THREAD_TEST_F(
+ LayerTreeHostScrollTestScrollRootScrollLayer_DeviceScaleFactor2)
+
} // namespace
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698