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

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

Issue 227683006: Remove ImageTransportFactory::CreateTransportClient (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use GLuint Created 6 years, 8 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
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 "base/run_loop.h" 5 #include "base/run_loop.h"
6 #include "cc/output/context_provider.h" 6 #include "cc/output/context_provider.h"
7 #include "content/browser/compositor/image_transport_factory.h" 7 #include "content/browser/compositor/image_transport_factory.h"
8 #include "content/public/browser/gpu_data_manager.h" 8 #include "content/public/browser/gpu_data_manager.h"
9 #include "content/public/test/content_browser_test.h" 9 #include "content/public/test/content_browser_test.h"
10 #include "gpu/GLES2/gl2extchromium.h" 10 #include "gpu/GLES2/gl2extchromium.h"
(...skipping 20 matching lines...) Expand all
31 #endif 31 #endif
32 // Checks that upon context loss, the observer is called and the created 32 // Checks that upon context loss, the observer is called and the created
33 // resources are reset. 33 // resources are reset.
34 IN_PROC_BROWSER_TEST_F(ImageTransportFactoryBrowserTest, 34 IN_PROC_BROWSER_TEST_F(ImageTransportFactoryBrowserTest,
35 MAYBE_TestLostContext) { 35 MAYBE_TestLostContext) {
36 // This test doesn't make sense in software compositing mode. 36 // This test doesn't make sense in software compositing mode.
37 if (!GpuDataManager::GetInstance()->CanUseGpuBrowserCompositor()) 37 if (!GpuDataManager::GetInstance()->CanUseGpuBrowserCompositor())
38 return; 38 return;
39 39
40 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 40 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
41 scoped_refptr<ui::Texture> texture = factory->CreateTransportClient(1.f); 41 ui::ContextFactory* context_factory = ui::ContextFactory::GetInstance();
42 gpu::gles2::GLES2Interface* gl =
43 context_factory->SharedMainThreadContextProvider()->ContextGL();
44 GLuint texture_id = 0;
45 gl->GenTextures(1, &texture_id);
46
47 scoped_refptr<ui::Texture> texture =
48 factory->CreateOwnedTexture(gfx::Size(1, 1), 1.f, texture_id);
42 ASSERT_TRUE(texture.get()); 49 ASSERT_TRUE(texture.get());
43 50
44 MockImageTransportFactoryObserver observer; 51 MockImageTransportFactoryObserver observer;
45 factory->AddObserver(&observer); 52 factory->AddObserver(&observer);
46 53
47 base::RunLoop run_loop; 54 base::RunLoop run_loop;
48 EXPECT_CALL(observer, OnLostResources()) 55 EXPECT_CALL(observer, OnLostResources())
49 .WillOnce(testing::InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); 56 .WillOnce(testing::InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
50 57
51 ui::ContextFactory* context_factory = ui::ContextFactory::GetInstance();
52
53 gpu::gles2::GLES2Interface* gl =
54 context_factory->SharedMainThreadContextProvider()->ContextGL();
55 gl->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, 58 gl->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
56 GL_INNOCENT_CONTEXT_RESET_ARB); 59 GL_INNOCENT_CONTEXT_RESET_ARB);
57 60
58 // We have to flush to make sure that the client side gets a chance to notice 61 // We have to flush to make sure that the client side gets a chance to notice
59 // the context is gone. 62 // the context is gone.
60 gl->Flush(); 63 gl->Flush();
61 64
62 run_loop.Run(); 65 run_loop.Run();
63 EXPECT_EQ(0u, texture->PrepareTexture()); 66 EXPECT_EQ(0u, texture->PrepareTexture());
64 67
65 factory->RemoveObserver(&observer); 68 factory->RemoveObserver(&observer);
66 } 69 }
67 70
68 } // anonymous namespace 71 } // anonymous namespace
69 } // namespace content 72 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698