OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
7 #include "mojo/gpu/gl_context.h" | 7 #include "mojo/gpu/gl_context.h" |
8 #include "mojo/gpu/gl_texture.h" | 8 #include "mojo/gpu/gl_texture.h" |
9 #include "mojo/public/cpp/application/application_impl.h" | 9 #include "mojo/public/cpp/application/application_impl.h" |
10 #include "mojo/public/cpp/application/application_test_base.h" | 10 #include "mojo/public/cpp/application/application_test_base.h" |
| 11 #include "mojo/public/cpp/application/connect.h" |
11 #include "mojo/services/geometry/interfaces/geometry.mojom.h" | 12 #include "mojo/services/geometry/interfaces/geometry.mojom.h" |
12 #include "mojo/services/gfx/composition/interfaces/resources.mojom.h" | 13 #include "mojo/services/gfx/composition/interfaces/resources.mojom.h" |
13 #include "mojo/ui/gl_renderer.h" | 14 #include "mojo/ui/gl_renderer.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 | 16 |
16 using mojo::gfx::composition::MailboxTextureCallbackPtr; | 17 using mojo::gfx::composition::MailboxTextureCallbackPtr; |
17 | 18 |
18 namespace { | 19 namespace { |
19 | 20 |
20 static const base::TimeDelta kDefaultMessageDelay = | 21 static const base::TimeDelta kDefaultMessageDelay = |
21 base::TimeDelta::FromMilliseconds(20); | 22 base::TimeDelta::FromMilliseconds(20); |
22 | 23 |
23 class GLRendererTest : public mojo::test::ApplicationTestBase { | 24 class GLRendererTest : public mojo::test::ApplicationTestBase { |
24 public: | 25 public: |
25 GLRendererTest() : weak_factory_(this) {} | 26 GLRendererTest() : weak_factory_(this) {} |
26 ~GLRendererTest() override {} | 27 ~GLRendererTest() override {} |
27 | 28 |
28 void SetUp() override { | 29 void SetUp() override { |
29 mojo::test::ApplicationTestBase::SetUp(); | 30 mojo::test::ApplicationTestBase::SetUp(); |
30 gl_context_ = mojo::GLContext::CreateOffscreen( | 31 gl_context_ = mojo::GLContext::CreateOffscreen( |
31 mojo::ApplicationConnectorPtr::Create( | 32 mojo::ApplicationConnectorPtr::Create( |
32 application_impl()->CreateApplicationConnector()) | 33 mojo::CreateApplicationConnector(application_impl()->shell())) |
33 .get()); | 34 .get()); |
34 quit_message_loop_callback_ = base::Bind( | 35 quit_message_loop_callback_ = base::Bind( |
35 &GLRendererTest::QuitMessageLoopCallback, weak_factory_.GetWeakPtr()); | 36 &GLRendererTest::QuitMessageLoopCallback, weak_factory_.GetWeakPtr()); |
36 } | 37 } |
37 | 38 |
38 void QuitMessageLoopCallback() { base::MessageLoop::current()->Quit(); } | 39 void QuitMessageLoopCallback() { base::MessageLoop::current()->Quit(); } |
39 | 40 |
40 void KickMessageLoop() { | 41 void KickMessageLoop() { |
41 base::MessageLoop::current()->PostDelayedTask( | 42 base::MessageLoop::current()->PostDelayedTask( |
42 FROM_HERE, quit_message_loop_callback_, kDefaultMessageDelay); | 43 FROM_HERE, quit_message_loop_callback_, kDefaultMessageDelay); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 gl_context_ = nullptr; | 195 gl_context_ = nullptr; |
195 | 196 |
196 MailboxTextureCallbackPtr::Create( | 197 MailboxTextureCallbackPtr::Create( |
197 std::move(resource1->get_mailbox_texture()->callback)) | 198 std::move(resource1->get_mailbox_texture()->callback)) |
198 ->OnMailboxTextureReleased(); | 199 ->OnMailboxTextureReleased(); |
199 | 200 |
200 KickMessageLoop(); | 201 KickMessageLoop(); |
201 } | 202 } |
202 | 203 |
203 } // namespace | 204 } // namespace |
OLD | NEW |