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