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

Side by Side Diff: cc/layer_tree_host_unittest_context.cc

Issue 11941010: Fix scrollbars missing after lost context (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: move test Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | cc/scrollbar_layer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/layer_tree_host.h" 5 #include "cc/layer_tree_host.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "cc/content_layer.h" 8 #include "cc/content_layer.h"
9 #include "cc/delegated_renderer_layer.h" 9 #include "cc/delegated_renderer_layer.h"
10 #include "cc/delegated_renderer_layer_impl.h" 10 #include "cc/delegated_renderer_layer_impl.h"
11 #include "cc/heads_up_display_layer.h" 11 #include "cc/heads_up_display_layer.h"
12 #include "cc/io_surface_layer.h" 12 #include "cc/io_surface_layer.h"
13 #include "cc/layer_impl.h" 13 #include "cc/layer_impl.h"
14 #include "cc/layer_tree_host_impl.h" 14 #include "cc/layer_tree_host_impl.h"
15 #include "cc/layer_tree_impl.h" 15 #include "cc/layer_tree_impl.h"
16 #include "cc/picture_layer.h" 16 #include "cc/picture_layer.h"
17 #include "cc/scrollbar_layer.h" 17 #include "cc/scrollbar_layer.h"
18 #include "cc/single_thread_proxy.h" 18 #include "cc/single_thread_proxy.h"
19 #include "cc/test/fake_content_layer.h" 19 #include "cc/test/fake_content_layer.h"
20 #include "cc/test/fake_content_layer_client.h" 20 #include "cc/test/fake_content_layer_client.h"
21 #include "cc/test/fake_content_layer_impl.h" 21 #include "cc/test/fake_content_layer_impl.h"
22 #include "cc/test/fake_output_surface.h" 22 #include "cc/test/fake_output_surface.h"
23 #include "cc/test/fake_scrollbar_layer.h"
23 #include "cc/test/fake_scrollbar_theme_painter.h" 24 #include "cc/test/fake_scrollbar_theme_painter.h"
24 #include "cc/test/fake_video_frame_provider.h" 25 #include "cc/test/fake_video_frame_provider.h"
25 #include "cc/test/fake_web_graphics_context_3d.h" 26 #include "cc/test/fake_web_graphics_context_3d.h"
26 #include "cc/test/fake_web_scrollbar.h" 27 #include "cc/test/fake_web_scrollbar.h"
27 #include "cc/test/fake_web_scrollbar_theme_geometry.h" 28 #include "cc/test/fake_web_scrollbar_theme_geometry.h"
28 #include "cc/test/layer_tree_test_common.h" 29 #include "cc/test/layer_tree_test_common.h"
29 #include "cc/test/render_pass_test_common.h" 30 #include "cc/test/render_pass_test_common.h"
30 #include "cc/texture_layer.h" 31 #include "cc/texture_layer.h"
31 #include "cc/video_layer.h" 32 #include "cc/video_layer.h"
32 #include "cc/video_layer_impl.h" 33 #include "cc/video_layer_impl.h"
34 #include "gpu/GLES2/gl2extchromium.h"
33 #include "media/base/media.h" 35 #include "media/base/media.h"
34 36
35 using media::VideoFrame; 37 using media::VideoFrame;
36 using WebKit::WebGraphicsContext3D; 38 using WebKit::WebGraphicsContext3D;
37 39
38 namespace cc { 40 namespace cc {
39 namespace { 41 namespace {
40 42
41 // These tests deal with losing the 3d graphics context. 43 // These tests deal with losing the 3d graphics context.
42 class LayerTreeHostContextTest : public ThreadedTest { 44 class LayerTreeHostContextTest : public ThreadedTest {
43 public: 45 public:
44 LayerTreeHostContextTest() 46 LayerTreeHostContextTest()
45 : ThreadedTest(), 47 : ThreadedTest(),
46 context3d_(NULL), 48 context3d_(NULL),
47 times_to_fail_create_(0), 49 times_to_fail_create_(0),
48 times_to_create_and_lose_(0), 50 times_to_create_and_lose_(0),
49 times_to_lose_during_commit_(0), 51 times_to_lose_during_commit_(0),
50 times_to_repeat_loss_(0), 52 times_to_repeat_loss_(0),
51 times_to_fail_recreate_(0) { 53 times_to_fail_recreate_(0) {
52 media::InitializeMediaLibraryForTesting(); 54 media::InitializeMediaLibraryForTesting();
53 } 55 }
54 56
55 void LoseContext() { 57 void LoseContext() {
56 context3d_->loseContextCHROMIUM(); 58 context3d_->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
59 GL_INNOCENT_CONTEXT_RESET_ARB);
57 context3d_ = NULL; 60 context3d_ = NULL;
58 } 61 }
59 62
60 virtual scoped_ptr<FakeWebGraphicsContext3D> CreateContext3d() { 63 virtual scoped_ptr<FakeWebGraphicsContext3D> CreateContext3d() {
61 return FakeWebGraphicsContext3D::Create(); 64 return FakeWebGraphicsContext3D::Create();
62 } 65 }
63 66
64 virtual scoped_ptr<OutputSurface> createOutputSurface() OVERRIDE { 67 virtual scoped_ptr<OutputSurface> createOutputSurface() OVERRIDE {
65 if (times_to_fail_create_) { 68 if (times_to_fail_create_) {
66 --times_to_fail_create_; 69 --times_to_fail_create_;
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 virtual void beginTest() OVERRIDE { 799 virtual void beginTest() OVERRIDE {
797 postSetNeedsCommitToMainThread(); 800 postSetNeedsCommitToMainThread();
798 } 801 }
799 802
800 virtual void afterTest() OVERRIDE { 803 virtual void afterTest() OVERRIDE {
801 } 804 }
802 805
803 virtual scoped_ptr<FakeWebGraphicsContext3D> CreateContext3d() OVERRIDE { 806 virtual scoped_ptr<FakeWebGraphicsContext3D> CreateContext3d() OVERRIDE {
804 scoped_ptr<FakeWebGraphicsContext3D> context = 807 scoped_ptr<FakeWebGraphicsContext3D> context =
805 LayerTreeHostContextTest::CreateContext3d(); 808 LayerTreeHostContextTest::CreateContext3d();
806 context->loseContextCHROMIUM(); 809 context->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
810 GL_INNOCENT_CONTEXT_RESET_ARB);
807 return context.Pass(); 811 return context.Pass();
808 } 812 }
809 813
810 virtual void didRecreateOutputSurface(bool succeeded) OVERRIDE { 814 virtual void didRecreateOutputSurface(bool succeeded) OVERRIDE {
811 EXPECT_FALSE(succeeded); 815 EXPECT_FALSE(succeeded);
812 // If we make it this far without crashing, we pass! 816 // If we make it this far without crashing, we pass!
813 endTest(); 817 endTest();
814 } 818 }
815 }; 819 };
816 820
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 EXPECT_TRUE(succeeded); 858 EXPECT_TRUE(succeeded);
855 endTest(); 859 endTest();
856 } 860 }
857 861
858 private: 862 private:
859 FakeContentLayerClient client_; 863 FakeContentLayerClient client_;
860 }; 864 };
861 865
862 MULTI_THREAD_TEST_F(LayerTreeHostContextTestImplSidePainting) 866 MULTI_THREAD_TEST_F(LayerTreeHostContextTestImplSidePainting)
863 867
868 class ScrollbarLayerLostContext : public LayerTreeHostContextTest {
869 public:
danakj 2013/01/18 23:16:20 nit: 1 space before
piman 2013/01/18 23:29:14 Done.
870 ScrollbarLayerLostContext() : commits_(0) {}
871
872 virtual void beginTest() OVERRIDE {
873 scoped_refptr<Layer> scroll_layer = Layer::create();
danakj 2013/01/18 23:16:20 nit: 2space indents
piman 2013/01/18 23:29:14 Done.
874 scrollbar_layer_ = FakeScrollbarLayer::Create(
875 false, true, scroll_layer->id());
876 scrollbar_layer_->setBounds(gfx::Size(10, 100));
877 m_layerTreeHost->rootLayer()->addChild(scrollbar_layer_);
878 m_layerTreeHost->rootLayer()->addChild(scroll_layer);
879 postSetNeedsCommitToMainThread();
880 }
881
882 virtual void afterTest() OVERRIDE {
883 }
884
885 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE {
886 ++commits_;
887 size_t upload_count = scrollbar_layer_->last_update_full_upload_size() +
888 scrollbar_layer_->last_update_partial_upload_size();
889 switch(commits_) {
890 case 1:
891 // First (regular) update, we should upload 2 resources (thumb, and
892 // backtrack).
893 EXPECT_EQ(1, scrollbar_layer_->update_count());
894 EXPECT_EQ(2, upload_count);
895 LoseContext();
896 break;
897 case 2:
898 // Second update, after the lost context, we should still upload 2
899 // resources even if the contents haven't changed.
900 EXPECT_EQ(2, scrollbar_layer_->update_count());
901 EXPECT_EQ(2, upload_count);
902 endTest();
903 break;
904 }
905 }
906
907 private:
908 int commits_;
909 scoped_refptr<FakeScrollbarLayer> scrollbar_layer_;
910 };
911
912 SINGLE_AND_MULTI_THREAD_TEST_F(ScrollbarLayerLostContext)
913
864 } // namespace 914 } // namespace
865 } // namespace cc 915 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/scrollbar_layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698