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

Side by Side Diff: content/browser/compositor/image_transport_factory_browsertest.cc

Issue 2083853002: exo: Recreate Surface resources on context lost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix nits Created 4 years, 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/browser/compositor/image_transport_factory.h" 5 #include "content/browser/compositor/image_transport_factory.h"
6 6
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "cc/output/context_provider.h" 9 #include "cc/output/context_provider.h"
10 #include "content/browser/compositor/owned_mailbox.h" 10 #include "content/browser/compositor/owned_mailbox.h"
11 #include "content/public/browser/gpu_data_manager.h" 11 #include "content/public/browser/gpu_data_manager.h"
12 #include "content/public/test/content_browser_test.h" 12 #include "content/public/test/content_browser_test.h"
13 #include "gpu/GLES2/gl2extchromium.h" 13 #include "gpu/GLES2/gl2extchromium.h"
14 #include "gpu/command_buffer/client/gles2_interface.h" 14 #include "gpu/command_buffer/client/gles2_interface.h"
15 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
16 #include "ui/compositor/compositor.h" 16 #include "ui/compositor/compositor.h"
17 17
18 namespace content { 18 namespace content {
19 namespace { 19 namespace {
20 20
21 typedef ContentBrowserTest ImageTransportFactoryBrowserTest; 21 typedef ContentBrowserTest ImageTransportFactoryBrowserTest;
22 22
23 class MockImageTransportFactoryObserver : public ImageTransportFactoryObserver { 23 class MockContextFactoryObserver : public ui::ContextFactoryObserver {
24 public: 24 public:
25 MOCK_METHOD0(OnLostResources, void()); 25 MOCK_METHOD0(OnLostResources, void());
26 }; 26 };
27 27
28 // This crashes on Mac ASAN: http://crbug.com/335083 28 // This crashes on Mac ASAN: http://crbug.com/335083
29 // Flaky on ChromeOS: crbug.com/394083 29 // Flaky on ChromeOS: crbug.com/394083
30 #if defined(OS_MACOSX) || defined(OS_CHROMEOS) 30 #if defined(OS_MACOSX) || defined(OS_CHROMEOS)
31 #define MAYBE_TestLostContext DISABLED_TestLostContext 31 #define MAYBE_TestLostContext DISABLED_TestLostContext
32 #else 32 #else
33 #define MAYBE_TestLostContext TestLostContext 33 #define MAYBE_TestLostContext TestLostContext
34 #endif 34 #endif
35 // Checks that upon context loss, the observer is called and the created 35 // Checks that upon context loss, the observer is called and the created
36 // resources are reset. 36 // resources are reset.
37 IN_PROC_BROWSER_TEST_F(ImageTransportFactoryBrowserTest, 37 IN_PROC_BROWSER_TEST_F(ImageTransportFactoryBrowserTest,
38 MAYBE_TestLostContext) { 38 MAYBE_TestLostContext) {
39 // This test doesn't make sense in software compositing mode. 39 // This test doesn't make sense in software compositing mode.
40 if (!GpuDataManager::GetInstance()->CanUseGpuBrowserCompositor()) 40 if (!GpuDataManager::GetInstance()->CanUseGpuBrowserCompositor())
41 return; 41 return;
42 42
43 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 43 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
44 44
45 scoped_refptr<OwnedMailbox> mailbox = 45 scoped_refptr<OwnedMailbox> mailbox =
46 new OwnedMailbox(factory->GetGLHelper()); 46 new OwnedMailbox(factory->GetGLHelper());
47 EXPECT_FALSE(mailbox->mailbox().IsZero()); 47 EXPECT_FALSE(mailbox->mailbox().IsZero());
48 48
49 MockImageTransportFactoryObserver observer; 49 MockContextFactoryObserver observer;
50 factory->AddObserver(&observer); 50 factory->GetContextFactory()->AddObserver(&observer);
51 51
52 base::RunLoop run_loop; 52 base::RunLoop run_loop;
53 EXPECT_CALL(observer, OnLostResources()) 53 EXPECT_CALL(observer, OnLostResources())
54 .WillOnce(testing::InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); 54 .WillOnce(testing::InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
55 55
56 ui::ContextFactory* context_factory = factory->GetContextFactory(); 56 ui::ContextFactory* context_factory = factory->GetContextFactory();
57 gpu::gles2::GLES2Interface* gl = 57 gpu::gles2::GLES2Interface* gl =
58 context_factory->SharedMainThreadContextProvider()->ContextGL(); 58 context_factory->SharedMainThreadContextProvider()->ContextGL();
59 gl->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, 59 gl->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
60 GL_INNOCENT_CONTEXT_RESET_ARB); 60 GL_INNOCENT_CONTEXT_RESET_ARB);
61 61
62 // We have to flush to make sure that the client side gets a chance to notice 62 // We have to flush to make sure that the client side gets a chance to notice
63 // the context is gone. 63 // the context is gone.
64 gl->Flush(); 64 gl->Flush();
65 65
66 run_loop.Run(); 66 run_loop.Run();
67 EXPECT_TRUE(mailbox->mailbox().IsZero()); 67 EXPECT_TRUE(mailbox->mailbox().IsZero());
68 68
69 factory->RemoveObserver(&observer); 69 factory->GetContextFactory()->RemoveObserver(&observer);
70 } 70 }
71 71
72 class ImageTransportFactoryTearDownBrowserTest : public ContentBrowserTest { 72 class ImageTransportFactoryTearDownBrowserTest : public ContentBrowserTest {
73 public: 73 public:
74 ImageTransportFactoryTearDownBrowserTest() {} 74 ImageTransportFactoryTearDownBrowserTest() {}
75 75
76 void TearDown() override { 76 void TearDown() override {
77 if (mailbox_.get()) 77 if (mailbox_.get())
78 EXPECT_TRUE(mailbox_->mailbox().IsZero()); 78 EXPECT_TRUE(mailbox_->mailbox().IsZero());
79 ContentBrowserTest::TearDown(); 79 ContentBrowserTest::TearDown();
(...skipping 22 matching lines...) Expand all
102 return; 102 return;
103 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 103 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
104 display_compositor::GLHelper* helper = factory->GetGLHelper(); 104 display_compositor::GLHelper* helper = factory->GetGLHelper();
105 ASSERT_TRUE(helper); 105 ASSERT_TRUE(helper);
106 mailbox_ = new OwnedMailbox(helper); 106 mailbox_ = new OwnedMailbox(helper);
107 EXPECT_FALSE(mailbox_->mailbox().IsZero()); 107 EXPECT_FALSE(mailbox_->mailbox().IsZero());
108 } 108 }
109 109
110 } // anonymous namespace 110 } // anonymous namespace
111 } // namespace content 111 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/compositor/image_transport_factory.h ('k') | content/browser/compositor/owned_mailbox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698