| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "mojo/gpu/texture_uploader.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "base/message_loop/message_loop.h" | |
| 9 #include "mojo/gpu/texture_cache.h" | |
| 10 #include "mojo/public/cpp/application/application_impl.h" | |
| 11 #include "mojo/public/cpp/application/application_test_base.h" | |
| 12 #include "mojo/public/cpp/application/connect.h" | |
| 13 #include "mojo/services/surfaces/interfaces/surface_id.mojom.h" | |
| 14 #include "testing/gtest/include/gtest/gtest.h" | |
| 15 | |
| 16 namespace { | |
| 17 | |
| 18 class TextureUploaderTest : public mojo::test::ApplicationTestBase { | |
| 19 public: | |
| 20 TextureUploaderTest() : surface_id_(1u), weak_factory_(this) {} | |
| 21 ~TextureUploaderTest() override {} | |
| 22 | |
| 23 void SetUp() override { | |
| 24 mojo::test::ApplicationTestBase::SetUp(); | |
| 25 | |
| 26 mojo::ServiceProviderPtr surfaces_service_provider; | |
| 27 application_impl()->shell()->ConnectToApplication( | |
| 28 "mojo:surfaces_service", mojo::GetProxy(&surfaces_service_provider), | |
| 29 nullptr); | |
| 30 mojo::ConnectToService(surfaces_service_provider.get(), &surface_); | |
| 31 gl_context_ = mojo::GLContext::Create(application_impl()->shell()); | |
| 32 surface_->CreateSurface(surface_id_); | |
| 33 texture_cache_.reset(new mojo::TextureCache(gl_context_, nullptr)); | |
| 34 } | |
| 35 | |
| 36 void OnFrameCompleteExit() { base::MessageLoop::current()->Quit(); } | |
| 37 | |
| 38 protected: | |
| 39 uint32_t surface_id_; | |
| 40 base::WeakPtr<mojo::GLContext> gl_context_; | |
| 41 scoped_ptr<mojo::TextureCache> texture_cache_; | |
| 42 mojo::SurfacePtr surface_; | |
| 43 base::WeakPtrFactory<TextureUploaderTest> weak_factory_; | |
| 44 | |
| 45 private: | |
| 46 DISALLOW_COPY_AND_ASSIGN(TextureUploaderTest); | |
| 47 }; | |
| 48 | |
| 49 TEST_F(TextureUploaderTest, Base) { | |
| 50 mojo::Size size; | |
| 51 size.width = 100; | |
| 52 size.height = 100; | |
| 53 scoped_ptr<mojo::TextureCache::TextureInfo> texture_info( | |
| 54 texture_cache_->GetTexture(size).Pass()); | |
| 55 mojo::FramePtr frame = mojo::TextureUploader::GetUploadFrame( | |
| 56 gl_context_, texture_info->resource_id(), texture_info->TakeTexture()); | |
| 57 EXPECT_FALSE(frame.is_null()); | |
| 58 } | |
| 59 | |
| 60 } // namespace | |
| OLD | NEW |