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

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

Issue 25367003: aura: Attach lost context callback to the shared main thread context (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add test Created 7 years, 2 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 | « content/browser/aura/gpu_process_transport_factory.cc ('k') | content/content_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/run_loop.h"
6 #include "content/browser/aura/image_transport_factory.h"
7 #include "content/test/content_browser_test.h"
8 #include "gpu/GLES2/gl2extchromium.h"
9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
11 #include "ui/compositor/compositor.h"
12
13 namespace content {
14 namespace {
15
16 class ImageTransportFactoryBrowserTest : public ContentBrowserTest {
17 public:
18 ImageTransportFactoryBrowserTest() {}
19
20 virtual void SetUp() OVERRIDE {
21 UseRealGLContexts();
22 ContentBrowserTest::SetUp();
23 }
24 };
25
26 class MockImageTransportFactoryObserver : public ImageTransportFactoryObserver {
27 public:
28 MOCK_METHOD0(OnLostResources, void());
29 };
30
31 // Checks that upon context loss, the observer is called and the created
32 // resources are reset.
33 IN_PROC_BROWSER_TEST_F(ImageTransportFactoryBrowserTest, TestLostContext) {
34 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
35 scoped_refptr<ui::Texture> texture = factory->CreateTransportClient(1.f);
36
37 MockImageTransportFactoryObserver observer;
38 factory->AddObserver(&observer);
39
40 base::RunLoop run_loop;
41 EXPECT_CALL(observer, OnLostResources())
42 .WillOnce(testing::InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
43
44 WebKit::WebGraphicsContext3D* context = texture->HostContext3D();
45 context->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
46 GL_INNOCENT_CONTEXT_RESET_ARB);
47
48 run_loop.Run();
49 EXPECT_FALSE(texture->HostContext3D());
50 EXPECT_EQ(0u, texture->PrepareTexture());
51
52 factory->RemoveObserver(&observer);
53 }
54
55 } // anonymous namespace
56 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/aura/gpu_process_transport_factory.cc ('k') | content/content_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698