Chromium Code Reviews| Index: cc/scrollbar_layer_unittest.cc |
| diff --git a/cc/scrollbar_layer_unittest.cc b/cc/scrollbar_layer_unittest.cc |
| index e6a7bff0b3067757693a358b602684fbf7b6c92b..b9be950f15b6473ab3b951c67d6c0285e5bdc955 100644 |
| --- a/cc/scrollbar_layer_unittest.cc |
| +++ b/cc/scrollbar_layer_unittest.cc |
| @@ -9,12 +9,14 @@ |
| #include "cc/single_thread_proxy.h" |
| #include "cc/test/fake_impl_proxy.h" |
| #include "cc/test/fake_layer_tree_host_impl.h" |
| +#include "cc/test/fake_scrollbar_layer.h" |
| #include "cc/test/fake_scrollbar_theme_painter.h" |
| #include "cc/test/fake_web_graphics_context_3d.h" |
| #include "cc/test/fake_web_scrollbar.h" |
| #include "cc/test/fake_web_scrollbar_theme_geometry.h" |
| #include "cc/test/layer_tree_test_common.h" |
| #include "cc/tree_synchronizer.h" |
| +#include "gpu/GLES2/gl2extchromium.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| #include "third_party/WebKit/Source/Platform/chromium/public/WebScrollbar.h" |
| #include "third_party/WebKit/Source/Platform/chromium/public/WebScrollbarThemeGeometry.h" |
| @@ -194,5 +196,71 @@ TEST_F(ScrollbarLayerTestMaxTextureSize, runTest) { |
| runTest(true); |
| } |
| +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.
|
| +public: |
| + ScrollbarLayerLostContext() : m_commits(0), m_context(NULL) {} |
| + |
| + virtual void beginTest() OVERRIDE |
| + { |
| + 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.
|
| + |
| + m_scrollLayer = Layer::create(); |
| + m_scrollbarLayer = FakeScrollbarLayer::Create(false, true, m_scrollLayer->id()); |
| + m_scrollbarLayer->setBounds(gfx::Size(10, 100)); |
| + m_layerTreeHost->rootLayer()->addChild(m_scrollbarLayer); |
| + m_layerTreeHost->rootLayer()->addChild(m_scrollLayer); |
| + postSetNeedsCommitToMainThread(); |
| + } |
| + |
| + virtual void afterTest() OVERRIDE |
| + { |
| + } |
| + |
| + virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE |
| + { |
| + ++m_commits; |
| + switch(m_commits) { |
| + case 1: |
| + // First (regular) update, we should upload 2 resources (thumb, and |
| + // backtrack). |
| + EXPECT_EQ(1, m_scrollbarLayer->update_count()); |
| + EXPECT_EQ(0, m_scrollbarLayer->last_update_full_upload_size()); |
| + EXPECT_EQ(2, m_scrollbarLayer->last_update_partial_upload_size()); |
| + loseContext(); |
| + break; |
| + case 2: |
| + // Second update, after the lost context, we should still upload 2 |
| + // resources even if the contents haven't changed. |
| + EXPECT_EQ(2, m_scrollbarLayer->update_count()); |
| + EXPECT_EQ(0, m_scrollbarLayer->last_update_full_upload_size()); |
| + EXPECT_EQ(2, m_scrollbarLayer->last_update_partial_upload_size()); |
| + endTest(); |
| + break; |
| + } |
| + } |
| + |
| + virtual scoped_ptr<OutputSurface> createOutputSurface() OVERRIDE { |
| + DCHECK(!m_context); |
| + scoped_ptr<OutputSurface> outputSurface = TestHooks::createOutputSurface(); |
| + m_context = outputSurface->Context3D(); |
| + return outputSurface.Pass(); |
| + } |
| + |
| +private: |
| + void loseContext() { |
| + DCHECK(m_context); |
| + m_context->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
| + GL_INNOCENT_CONTEXT_RESET_ARB); |
| + m_context = NULL; |
| + } |
| + |
| + int m_commits; |
| + WebKit::WebGraphicsContext3D* m_context; |
| + scoped_refptr<FakeScrollbarLayer> m_scrollbarLayer; |
| + scoped_refptr<Layer> m_scrollLayer; |
| +}; |
| + |
| +SINGLE_AND_MULTI_THREAD_TEST_F(ScrollbarLayerLostContext) |
| + |
| } // namespace |
| } // namespace cc |