Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/scrollbar_layer.h" | 5 #include "cc/scrollbar_layer.h" |
| 6 | 6 |
| 7 #include "cc/scrollbar_animation_controller.h" | 7 #include "cc/scrollbar_animation_controller.h" |
| 8 #include "cc/scrollbar_layer_impl.h" | 8 #include "cc/scrollbar_layer_impl.h" |
| 9 #include "cc/single_thread_proxy.h" | 9 #include "cc/single_thread_proxy.h" |
| 10 #include "cc/test/fake_impl_proxy.h" | 10 #include "cc/test/fake_impl_proxy.h" |
| 11 #include "cc/test/fake_layer_tree_host_impl.h" | 11 #include "cc/test/fake_layer_tree_host_impl.h" |
| 12 #include "cc/test/fake_scrollbar_layer.h" | |
| 12 #include "cc/test/fake_scrollbar_theme_painter.h" | 13 #include "cc/test/fake_scrollbar_theme_painter.h" |
| 13 #include "cc/test/fake_web_graphics_context_3d.h" | 14 #include "cc/test/fake_web_graphics_context_3d.h" |
| 14 #include "cc/test/fake_web_scrollbar.h" | 15 #include "cc/test/fake_web_scrollbar.h" |
| 15 #include "cc/test/fake_web_scrollbar_theme_geometry.h" | 16 #include "cc/test/fake_web_scrollbar_theme_geometry.h" |
| 16 #include "cc/test/layer_tree_test_common.h" | 17 #include "cc/test/layer_tree_test_common.h" |
| 17 #include "cc/tree_synchronizer.h" | 18 #include "cc/tree_synchronizer.h" |
| 19 #include "gpu/GLES2/gl2extchromium.h" | |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "third_party/WebKit/Source/Platform/chromium/public/WebScrollbar.h" | 21 #include "third_party/WebKit/Source/Platform/chromium/public/WebScrollbar.h" |
| 20 #include "third_party/WebKit/Source/Platform/chromium/public/WebScrollbarThemeGe ometry.h" | 22 #include "third_party/WebKit/Source/Platform/chromium/public/WebScrollbarThemeGe ometry.h" |
| 21 | 23 |
| 22 namespace cc { | 24 namespace cc { |
| 23 namespace { | 25 namespace { |
| 24 | 26 |
| 25 scoped_ptr<LayerImpl> layerImplForScrollAreaAndScrollbar( | 27 scoped_ptr<LayerImpl> layerImplForScrollAreaAndScrollbar( |
| 26 FakeLayerTreeHostImpl* host_impl, | 28 FakeLayerTreeHostImpl* host_impl, |
| 27 scoped_ptr<WebKit::WebScrollbar> scrollbar, | 29 scoped_ptr<WebKit::WebScrollbar> scrollbar, |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 }; | 189 }; |
| 188 | 190 |
| 189 TEST_F(ScrollbarLayerTestMaxTextureSize, runTest) { | 191 TEST_F(ScrollbarLayerTestMaxTextureSize, runTest) { |
| 190 scoped_ptr<FakeWebGraphicsContext3D> context = FakeWebGraphicsContext3D::Cre ate(); | 192 scoped_ptr<FakeWebGraphicsContext3D> context = FakeWebGraphicsContext3D::Cre ate(); |
| 191 int max_size = 0; | 193 int max_size = 0; |
| 192 context->getIntegerv(GL_MAX_TEXTURE_SIZE, &max_size); | 194 context->getIntegerv(GL_MAX_TEXTURE_SIZE, &max_size); |
| 193 setScrollbarBounds(gfx::Size(max_size + 100, max_size + 100)); | 195 setScrollbarBounds(gfx::Size(max_size + 100, max_size + 100)); |
| 194 runTest(true); | 196 runTest(true); |
| 195 } | 197 } |
| 196 | 198 |
| 199 class ScrollbarLayerLostContext : public ThreadedTest { | |
|
danakj
2013/01/18 05:07:49
Can you stick this in layer_tree_host_unittest_con
piman
2013/01/18 23:10:08
Done.
| |
| 200 public: | |
| 201 ScrollbarLayerLostContext() : m_commits(0), m_context(NULL) {} | |
| 202 | |
| 203 virtual void beginTest() OVERRIDE | |
| 204 { | |
| 205 m_layerTreeHost->initializeRendererIfNeeded(); | |
|
danakj
2013/01/18 05:07:49
this should be done by base classes already, shoul
piman
2013/01/18 23:10:08
Done.
| |
| 206 | |
| 207 m_scrollLayer = Layer::create(); | |
| 208 m_scrollbarLayer = FakeScrollbarLayer::Create(false, true, m_scrollLayer ->id()); | |
| 209 m_scrollbarLayer->setBounds(gfx::Size(10, 100)); | |
| 210 m_layerTreeHost->rootLayer()->addChild(m_scrollbarLayer); | |
| 211 m_layerTreeHost->rootLayer()->addChild(m_scrollLayer); | |
| 212 postSetNeedsCommitToMainThread(); | |
| 213 } | |
| 214 | |
| 215 virtual void afterTest() OVERRIDE | |
| 216 { | |
| 217 } | |
| 218 | |
| 219 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE | |
| 220 { | |
| 221 ++m_commits; | |
| 222 switch(m_commits) { | |
| 223 case 1: | |
| 224 // First (regular) update, we should upload 2 resources (thumb, and | |
| 225 // backtrack). | |
| 226 EXPECT_EQ(1, m_scrollbarLayer->update_count()); | |
| 227 EXPECT_EQ(0, m_scrollbarLayer->last_update_full_upload_size()); | |
| 228 EXPECT_EQ(2, m_scrollbarLayer->last_update_partial_upload_size()); | |
| 229 loseContext(); | |
| 230 break; | |
| 231 case 2: | |
| 232 // Second update, after the lost context, we should still upload 2 | |
| 233 // resources even if the contents haven't changed. | |
| 234 EXPECT_EQ(2, m_scrollbarLayer->update_count()); | |
| 235 EXPECT_EQ(0, m_scrollbarLayer->last_update_full_upload_size()); | |
| 236 EXPECT_EQ(2, m_scrollbarLayer->last_update_partial_upload_size()); | |
| 237 endTest(); | |
| 238 break; | |
| 239 } | |
| 240 } | |
| 241 | |
| 242 virtual scoped_ptr<OutputSurface> createOutputSurface() OVERRIDE { | |
| 243 DCHECK(!m_context); | |
| 244 scoped_ptr<OutputSurface> outputSurface = TestHooks::createOutputSurface (); | |
| 245 m_context = outputSurface->Context3D(); | |
| 246 return outputSurface.Pass(); | |
| 247 } | |
| 248 | |
| 249 private: | |
| 250 void loseContext() { | |
| 251 DCHECK(m_context); | |
| 252 m_context->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, | |
| 253 GL_INNOCENT_CONTEXT_RESET_ARB); | |
| 254 m_context = NULL; | |
| 255 } | |
| 256 | |
| 257 int m_commits; | |
| 258 WebKit::WebGraphicsContext3D* m_context; | |
| 259 scoped_refptr<FakeScrollbarLayer> m_scrollbarLayer; | |
| 260 scoped_refptr<Layer> m_scrollLayer; | |
| 261 }; | |
| 262 | |
| 263 SINGLE_AND_MULTI_THREAD_TEST_F(ScrollbarLayerLostContext) | |
| 264 | |
| 197 } // namespace | 265 } // namespace |
| 198 } // namespace cc | 266 } // namespace cc |
| OLD | NEW |