From 5abfd72765d29f36b577cdbb91ed7cfabc7560a7 Mon Sep 17 00:00:00 2001 From: altimin Date: Thu, 12 Nov 2015 10:40:58 -0800 Subject: Rename "test" ozone platform to "headless" This platform normally has no graphical output or user input support and has been used for running tests. Rename it to "headless" to describe what it does rather than what we've been using it for. BUG=546953 Review URL: https://codereview.chromium.org/1410123003 Cr-Commit-Position: refs/heads/master@{#359336} --- build/common.gypi | 8 +- chromecast/BUILD.gn | 2 +- chromecast/chromecast_tests.gypi | 2 +- media/ozone/media_ozone_platform.cc | 2 +- ui/ozone/BUILD.gn | 7 +- ui/ozone/ozone.gni | 10 +- ui/ozone/ozone.gyp | 4 +- ui/ozone/platform/headless/BUILD.gn | 27 +++++ ui/ozone/platform/headless/DEPS | 3 + .../client_native_pixmap_factory_headless.cc | 15 +++ .../client_native_pixmap_factory_headless.h | 17 +++ ui/ozone/platform/headless/headless.gypi | 43 +++++++ .../platform/headless/headless_surface_factory.cc | 91 +++++++++++++++ .../platform/headless/headless_surface_factory.h | 36 ++++++ ui/ozone/platform/headless/headless_window.cc | 77 ++++++++++++ ui/ozone/platform/headless/headless_window.h | 58 +++++++++ .../platform/headless/headless_window_manager.cc | 48 ++++++++ .../platform/headless/headless_window_manager.h | 51 ++++++++ .../platform/headless/ozone_platform_headless.cc | 130 +++++++++++++++++++++ .../platform/headless/ozone_platform_headless.h | 17 +++ ui/ozone/platform/test/BUILD.gn | 27 ----- ui/ozone/platform/test/DEPS | 3 - .../test/client_native_pixmap_factory_test.cc | 15 --- .../test/client_native_pixmap_factory_test.h | 17 --- ui/ozone/platform/test/ozone_platform_test.cc | 130 --------------------- ui/ozone/platform/test/ozone_platform_test.h | 17 --- ui/ozone/platform/test/test.gypi | 43 ------- ui/ozone/platform/test/test_surface_factory.cc | 88 -------------- ui/ozone/platform/test/test_surface_factory.h | 35 ------ ui/ozone/platform/test/test_window.cc | 90 -------------- ui/ozone/platform/test/test_window.h | 57 --------- ui/ozone/platform/test/test_window_manager.cc | 47 -------- ui/ozone/platform/test/test_window_manager.h | 50 -------- 33 files changed, 631 insertions(+), 636 deletions(-) create mode 100644 ui/ozone/platform/headless/BUILD.gn create mode 100644 ui/ozone/platform/headless/DEPS create mode 100644 ui/ozone/platform/headless/client_native_pixmap_factory_headless.cc create mode 100644 ui/ozone/platform/headless/client_native_pixmap_factory_headless.h create mode 100644 ui/ozone/platform/headless/headless.gypi create mode 100644 ui/ozone/platform/headless/headless_surface_factory.cc create mode 100644 ui/ozone/platform/headless/headless_surface_factory.h create mode 100644 ui/ozone/platform/headless/headless_window.cc create mode 100644 ui/ozone/platform/headless/headless_window.h create mode 100644 ui/ozone/platform/headless/headless_window_manager.cc create mode 100644 ui/ozone/platform/headless/headless_window_manager.h create mode 100644 ui/ozone/platform/headless/ozone_platform_headless.cc create mode 100644 ui/ozone/platform/headless/ozone_platform_headless.h delete mode 100644 ui/ozone/platform/test/BUILD.gn delete mode 100644 ui/ozone/platform/test/DEPS delete mode 100644 ui/ozone/platform/test/client_native_pixmap_factory_test.cc delete mode 100644 ui/ozone/platform/test/client_native_pixmap_factory_test.h delete mode 100644 ui/ozone/platform/test/ozone_platform_test.cc delete mode 100644 ui/ozone/platform/test/ozone_platform_test.h delete mode 100644 ui/ozone/platform/test/test.gypi delete mode 100644 ui/ozone/platform/test/test_surface_factory.cc delete mode 100644 ui/ozone/platform/test/test_surface_factory.h delete mode 100644 ui/ozone/platform/test/test_window.cc delete mode 100644 ui/ozone/platform/test/test_window.h delete mode 100644 ui/ozone/platform/test/test_window_manager.cc delete mode 100644 ui/ozone/platform/test/test_window_manager.h diff --git a/build/common.gypi b/build/common.gypi index b80d0f2..f44a972 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -1535,7 +1535,7 @@ 'ozone_platform_egltest%': 0, 'ozone_platform_gbm%': 0, 'ozone_platform_ozonex%': 0, - 'ozone_platform_test%': 0, + 'ozone_platform_headless%': 0, # Experiment: http://crbug.com/426914 'envoy%': 0, @@ -2363,13 +2363,13 @@ }], ['use_ozone==1 and ozone_auto_platforms==1', { - # Use test as the default platform. - 'ozone_platform%': 'test', + # Use headless as the default platform. + 'ozone_platform%': 'headless', # Build all platforms whose deps are in install-build-deps.sh. # Only these platforms will be compile tested by buildbots. 'ozone_platform_gbm%': 1, - 'ozone_platform_test%': 1, + 'ozone_platform_headless%': 1, 'ozone_platform_egltest%': 1, }], diff --git a/chromecast/BUILD.gn b/chromecast/BUILD.gn index 306af8a..6ac1963 100644 --- a/chromecast/BUILD.gn +++ b/chromecast/BUILD.gn @@ -137,7 +137,7 @@ cast_test_group_list("cast_test_lists") { run_list_path = "$root_out_dir/tests/run_test_list.txt" - additional_options = [ "--ozone-platform=test" ] + additional_options = [ "--ozone-platform=headless" ] build_tests = true diff --git a/chromecast/chromecast_tests.gypi b/chromecast/chromecast_tests.gypi index 53316ba..4eaea74 100644 --- a/chromecast/chromecast_tests.gypi +++ b/chromecast/chromecast_tests.gypi @@ -396,7 +396,7 @@ 'variables': { 'test_generator_py': '<(DEPTH)/chromecast/tools/build/generate_test_lists.py', 'test_inputs_dir': '<(SHARED_INTERMEDIATE_DIR)/chromecast/tests', - 'test_additional_options': '--ozone-platform=test' + 'test_additional_options': '--ozone-platform=headless' }, 'actions': [ { diff --git a/media/ozone/media_ozone_platform.cc b/media/ozone/media_ozone_platform.cc index cda1396..15d52c6 100644 --- a/media/ozone/media_ozone_platform.cc +++ b/media/ozone/media_ozone_platform.cc @@ -52,7 +52,7 @@ MediaOzonePlatform* CreateMediaOzonePlatformGbm() { return new MediaOzonePlatformStub; } -MediaOzonePlatform* CreateMediaOzonePlatformTest() { +MediaOzonePlatform* CreateMediaOzonePlatformHeadless() { return new MediaOzonePlatformStub; } diff --git a/ui/ozone/BUILD.gn b/ui/ozone/BUILD.gn index fb13cd3..f529692 100644 --- a/ui/ozone/BUILD.gn +++ b/ui/ozone/BUILD.gn @@ -19,9 +19,9 @@ if (ozone_platform_egltest) { ozone_platform_deps += [ "platform/egltest" ] } -if (ozone_platform_test) { - ozone_platforms += [ "test" ] - ozone_platform_deps += [ "platform/test" ] +if (ozone_platform_headless) { + ozone_platforms += [ "headless" ] + ozone_platform_deps += [ "platform/headless" ] } if (ozone_platform_caca) { @@ -131,6 +131,7 @@ component("ozone") { "//ui/display/types", "//ui/display/util", "//ui/events", + "//ui/events/devices", "//ui/events/ozone:events_ozone", "//ui/gfx", "//ui/gfx/geometry", diff --git a/ui/ozone/ozone.gni b/ui/ozone/ozone.gni index cb6f62e..15e909d 100644 --- a/ui/ozone/ozone.gni +++ b/ui/ozone/ozone.gni @@ -26,14 +26,14 @@ declare_args() { ozone_platform_egltest = false ozone_platform_gbm = false ozone_platform_ozonex = false - ozone_platform_test = false + ozone_platform_headless = false if (ozone_auto_platforms) { if (is_chromecast) { # The default platform used at runtime is "cast". ozone_platform = "cast" ozone_platform_cast = true - ozone_platform_test = true + ozone_platform_headless = true # For desktop Chromecast builds, override the default "cast" platform with # --ozone_platform=egltest @@ -42,13 +42,13 @@ declare_args() { ozone_platform_ozonex = true } } else { - # Use test as the default platform. - ozone_platform = "test" + # Use headless as the default platform. + ozone_platform = "headless" # Build all platforms whose deps are in install-build-deps.sh. # Only these platforms will be compile tested by buildbots. ozone_platform_gbm = true - ozone_platform_test = true + ozone_platform_headless = true ozone_platform_egltest = true } } diff --git a/ui/ozone/ozone.gyp b/ui/ozone/ozone.gyp index 1f4bfc4..d0b81a7 100644 --- a/ui/ozone/ozone.gyp +++ b/ui/ozone/ozone.gyp @@ -240,9 +240,9 @@ 'platform/drm/gbm.gypi', ], }], - ['<(ozone_platform_test) == 1', { + ['<(ozone_platform_headless) == 1', { 'includes': [ - 'platform/test/test.gypi', + 'platform/headless/headless.gypi', ], }], ], diff --git a/ui/ozone/platform/headless/BUILD.gn b/ui/ozone/platform/headless/BUILD.gn new file mode 100644 index 0000000..fb731a2 --- /dev/null +++ b/ui/ozone/platform/headless/BUILD.gn @@ -0,0 +1,27 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +source_set("headless") { + sources = [ + "client_native_pixmap_factory_headless.cc", + "client_native_pixmap_factory_headless.h", + "headless_surface_factory.cc", + "headless_surface_factory.h", + "headless_window.cc", + "headless_window.h", + "headless_window_manager.cc", + "headless_window_manager.h", + "ozone_platform_headless.cc", + "ozone_platform_headless.h", + ] + + deps = [ + "//base", + "//skia", + "//ui/base", + "//ui/gfx/geometry", + "//ui/events/ozone:events_ozone_layout", + "//ui/events/platform", + ] +} diff --git a/ui/ozone/platform/headless/DEPS b/ui/ozone/platform/headless/DEPS new file mode 100644 index 0000000..41cd997 --- /dev/null +++ b/ui/ozone/platform/headless/DEPS @@ -0,0 +1,3 @@ +include_rules = [ + "+third_party/skia/include", +] diff --git a/ui/ozone/platform/headless/client_native_pixmap_factory_headless.cc b/ui/ozone/platform/headless/client_native_pixmap_factory_headless.cc new file mode 100644 index 0000000..1f409eb --- /dev/null +++ b/ui/ozone/platform/headless/client_native_pixmap_factory_headless.cc @@ -0,0 +1,15 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/ozone/platform/headless/client_native_pixmap_factory_headless.h" + +#include "ui/ozone/common/stub_client_native_pixmap_factory.h" + +namespace ui { + +ClientNativePixmapFactory* CreateClientNativePixmapFactoryHeadless() { + return CreateStubClientNativePixmapFactory(); +} + +} // namespace ui diff --git a/ui/ozone/platform/headless/client_native_pixmap_factory_headless.h b/ui/ozone/platform/headless/client_native_pixmap_factory_headless.h new file mode 100644 index 0000000..675eec1 --- /dev/null +++ b/ui/ozone/platform/headless/client_native_pixmap_factory_headless.h @@ -0,0 +1,17 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_OZONE_PLATFORM_HEADLESS_CLIENT_NATIVE_PIXMAP_FACTORY_HEADLESS_H_ +#define UI_OZONE_PLATFORM_HEADLESS_CLIENT_NATIVE_PIXMAP_FACTORY_HEADLESS_H_ + +namespace ui { + +class ClientNativePixmapFactory; + +// Constructor hook for use in constructor_list.cc +ClientNativePixmapFactory* CreateClientNativePixmapFactoryHeadless(); + +} // namespace ui + +#endif // UI_OZONE_PLATFORM_HEADLESS_CLIENT_NATIVE_PIXMAP_FACTORY_HEADLESS_H_ diff --git a/ui/ozone/platform/headless/headless.gypi b/ui/ozone/platform/headless/headless.gypi new file mode 100644 index 0000000..65de1fa --- /dev/null +++ b/ui/ozone/platform/headless/headless.gypi @@ -0,0 +1,43 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +{ + 'variables': { + 'internal_ozone_platform_deps': [ + 'ozone_platform_headless', + ], + 'internal_ozone_platforms': [ + 'headless' + ], + }, + 'targets': [ + { + 'target_name': 'ozone_platform_headless', + 'type': 'static_library', + 'defines': [ + 'OZONE_IMPLEMENTATION', + ], + 'dependencies': [ + '../../base/base.gyp:base', + '../base/ui_base.gyp:ui_base', + '../events/events.gyp:events', + '../events/ozone/events_ozone.gyp:events_ozone_layout', + '../events/platform/events_platform.gyp:events_platform', + '../gfx/gfx.gyp:gfx', + ], + 'sources': [ + 'client_native_pixmap_factory_headless.cc', + 'client_native_pixmap_factory_headless.h', + 'ozone_platform_headless.cc', + 'ozone_platform_headless.h', + 'headless_surface_factory.cc', + 'headless_surface_factory.h', + 'headless_window.cc', + 'headless_window.h', + 'headless_window_manager.cc', + 'headless_window_manager.h', + ], + }, + ], +} diff --git a/ui/ozone/platform/headless/headless_surface_factory.cc b/ui/ozone/platform/headless/headless_surface_factory.cc new file mode 100644 index 0000000..3262e69 --- /dev/null +++ b/ui/ozone/platform/headless/headless_surface_factory.cc @@ -0,0 +1,91 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/ozone/platform/headless/headless_surface_factory.h" + +#include "base/bind.h" +#include "base/files/file_util.h" +#include "base/location.h" +#include "base/stl_util.h" +#include "base/threading/worker_pool.h" +#include "third_party/skia/include/core/SkCanvas.h" +#include "third_party/skia/include/core/SkSurface.h" +#include "ui/gfx/codec/png_codec.h" +#include "ui/gfx/skia_util.h" +#include "ui/gfx/vsync_provider.h" +#include "ui/ozone/platform/headless/headless_window.h" +#include "ui/ozone/platform/headless/headless_window_manager.h" +#include "ui/ozone/public/surface_ozone_canvas.h" + +namespace ui { + +namespace { + +void WriteDataToFile(const base::FilePath& location, const SkBitmap& bitmap) { + DCHECK(!location.empty()); + std::vector png_data; + gfx::PNGCodec::FastEncodeBGRASkBitmap(bitmap, true, &png_data); + base::WriteFile(location, + reinterpret_cast(vector_as_array(&png_data)), + png_data.size()); +} + +// TODO(altimin): Find a proper way to capture rendering output. +class FileSurface : public SurfaceOzoneCanvas { + public: + FileSurface(const base::FilePath& location) : location_(location) {} + ~FileSurface() override {} + + // SurfaceOzoneCanvas overrides: + void ResizeCanvas(const gfx::Size& viewport_size) override { + surface_ = skia::AdoptRef(SkSurface::NewRaster(SkImageInfo::MakeN32Premul( + viewport_size.width(), viewport_size.height()))); + } + skia::RefPtr GetSurface() override { return surface_; } + void PresentCanvas(const gfx::Rect& damage) override { + if (location_.empty()) + return; + SkBitmap bitmap; + bitmap.setInfo(surface_->getCanvas()->imageInfo()); + + // TODO(dnicoara) Use SkImage instead to potentially avoid a copy. + // See crbug.com/361605 for details. + if (surface_->getCanvas()->readPixels(&bitmap, 0, 0)) { + base::WorkerPool::PostTask( + FROM_HERE, base::Bind(&WriteDataToFile, location_, bitmap), true); + } + } + scoped_ptr CreateVSyncProvider() override { + return nullptr; + } + + private: + base::FilePath location_; + skia::RefPtr surface_; +}; + +} // namespace + +HeadlessSurfaceFactory::HeadlessSurfaceFactory() + : HeadlessSurfaceFactory(nullptr) {} + +HeadlessSurfaceFactory::HeadlessSurfaceFactory( + HeadlessWindowManager* window_manager) + : window_manager_(window_manager) {} + +HeadlessSurfaceFactory::~HeadlessSurfaceFactory() {} + +scoped_ptr HeadlessSurfaceFactory::CreateCanvasForWidget( + gfx::AcceleratedWidget widget) { + HeadlessWindow* window = window_manager_->GetWindow(widget); + return make_scoped_ptr(new FileSurface(window->path())); +} + +bool HeadlessSurfaceFactory::LoadEGLGLES2Bindings( + AddGLLibraryCallback add_gl_library, + SetGLGetProcAddressProcCallback set_gl_get_proc_address) { + return false; +} + +} // namespace ui diff --git a/ui/ozone/platform/headless/headless_surface_factory.h b/ui/ozone/platform/headless/headless_surface_factory.h new file mode 100644 index 0000000..b715cbc --- /dev/null +++ b/ui/ozone/platform/headless/headless_surface_factory.h @@ -0,0 +1,36 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_OZONE_PLATFORM_HEADLESS_HEADLESS_SURFACE_FACTORY_H_ +#define UI_OZONE_PLATFORM_HEADLESS_HEADLESS_SURFACE_FACTORY_H_ + +#include "base/macros.h" +#include "ui/ozone/public/surface_factory_ozone.h" + +namespace ui { + +class HeadlessWindowManager; + +class HeadlessSurfaceFactory : public SurfaceFactoryOzone { + public: + HeadlessSurfaceFactory(); + explicit HeadlessSurfaceFactory(HeadlessWindowManager* window_manager); + ~HeadlessSurfaceFactory() override; + + // SurfaceFactoryOzone: + scoped_ptr CreateCanvasForWidget( + gfx::AcceleratedWidget w) override; + bool LoadEGLGLES2Bindings( + AddGLLibraryCallback add_gl_library, + SetGLGetProcAddressProcCallback set_gl_get_proc_address) override; + + private: + HeadlessWindowManager* window_manager_; + + DISALLOW_COPY_AND_ASSIGN(HeadlessSurfaceFactory); +}; + +} // namespace ui + +#endif // UI_OZONE_PLATFORM_HEADLESS_HEADLESS_SURFACE_FACTORY_H_ diff --git a/ui/ozone/platform/headless/headless_window.cc b/ui/ozone/platform/headless/headless_window.cc new file mode 100644 index 0000000..75f86a1 --- /dev/null +++ b/ui/ozone/platform/headless/headless_window.cc @@ -0,0 +1,77 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/ozone/platform/headless/headless_window.h" + +#include + +#include "base/files/file_path.h" +#include "base/strings/string_number_conversions.h" +#include "ui/events/platform/platform_event_source.h" +#include "ui/ozone/platform/headless/headless_window_manager.h" +#include "ui/platform_window/platform_window_delegate.h" + +namespace ui { + +HeadlessWindow::HeadlessWindow(PlatformWindowDelegate* delegate, + HeadlessWindowManager* manager, + const gfx::Rect& bounds) + : delegate_(delegate), manager_(manager), bounds_(bounds) { + widget_ = manager_->AddWindow(this); + delegate_->OnAcceleratedWidgetAvailable(widget_, 1.f); +} + +HeadlessWindow::~HeadlessWindow() { + manager_->RemoveWindow(widget_, this); +} + +base::FilePath HeadlessWindow::path() { + base::FilePath base_path = manager_->base_path(); + if (base_path.empty() || base_path == base::FilePath("/dev/null")) + return base_path; + + // Disambiguate multiple window output files with the window id. + return base_path.Append(base::IntToString(widget_)); +} + +gfx::Rect HeadlessWindow::GetBounds() { + return bounds_; +} + +void HeadlessWindow::SetBounds(const gfx::Rect& bounds) { + bounds_ = bounds; + delegate_->OnBoundsChanged(bounds); +} + +void HeadlessWindow::SetTitle(const base::string16& title) {} + +void HeadlessWindow::Show() {} + +void HeadlessWindow::Hide() {} + +void HeadlessWindow::Close() {} + +void HeadlessWindow::SetCapture() {} + +void HeadlessWindow::ReleaseCapture() {} + +void HeadlessWindow::ToggleFullscreen() {} + +void HeadlessWindow::Maximize() {} + +void HeadlessWindow::Minimize() {} + +void HeadlessWindow::Restore() {} + +void HeadlessWindow::SetCursor(PlatformCursor cursor) {} + +void HeadlessWindow::MoveCursorTo(const gfx::Point& location) {} + +void HeadlessWindow::ConfineCursorToBounds(const gfx::Rect& bounds) {} + +PlatformImeController* HeadlessWindow::GetPlatformImeController() { + return nullptr; +} + +} // namespace ui diff --git a/ui/ozone/platform/headless/headless_window.h b/ui/ozone/platform/headless/headless_window.h new file mode 100644 index 0000000..5587b65 --- /dev/null +++ b/ui/ozone/platform/headless/headless_window.h @@ -0,0 +1,58 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_OZONE_PLATFORM_HEADLESS_HEADLESS_WINDOW_H_ +#define UI_OZONE_PLATFORM_HEADLESS_HEADLESS_WINDOW_H_ + +#include "base/files/file_path.h" +#include "base/macros.h" +#include "ui/gfx/geometry/rect.h" +#include "ui/gfx/native_widget_types.h" +#include "ui/platform_window/platform_window.h" + +namespace ui { + +class PlatformWindowDelegate; +class HeadlessWindowManager; + +class HeadlessWindow : public PlatformWindow { + public: + HeadlessWindow(PlatformWindowDelegate* delegate, + HeadlessWindowManager* manager, + const gfx::Rect& bounds); + ~HeadlessWindow() override; + + // Path for image file for this window. + base::FilePath path(); + + // PlatformWindow: + gfx::Rect GetBounds() override; + void SetBounds(const gfx::Rect& bounds) override; + void SetTitle(const base::string16& title) override; + void Show() override; + void Hide() override; + void Close() override; + void SetCapture() override; + void ReleaseCapture() override; + void ToggleFullscreen() override; + void Maximize() override; + void Minimize() override; + void Restore() override; + void SetCursor(PlatformCursor cursor) override; + void MoveCursorTo(const gfx::Point& location) override; + void ConfineCursorToBounds(const gfx::Rect& bounds) override; + PlatformImeController* GetPlatformImeController() override; + + private: + PlatformWindowDelegate* delegate_; + HeadlessWindowManager* manager_; + gfx::Rect bounds_; + gfx::AcceleratedWidget widget_; + + DISALLOW_COPY_AND_ASSIGN(HeadlessWindow); +}; + +} // namespace ui + +#endif // UI_OZONE_PLATFORM_HEADLESS_HEADLESS_WINDOW_H_ diff --git a/ui/ozone/platform/headless/headless_window_manager.cc b/ui/ozone/platform/headless/headless_window_manager.cc new file mode 100644 index 0000000..eb6b483 --- /dev/null +++ b/ui/ozone/platform/headless/headless_window_manager.cc @@ -0,0 +1,48 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/ozone/platform/headless/headless_window_manager.h" + +#include "base/files/file_util.h" +#include "base/location.h" + +namespace ui { + +HeadlessWindowManager::HeadlessWindowManager( + const base::FilePath& dump_location) + : location_(dump_location) {} + +HeadlessWindowManager::~HeadlessWindowManager() { + DCHECK(thread_checker_.CalledOnValidThread()); +} + +void HeadlessWindowManager::Initialize() { + if (location_.empty()) + return; + if (!DirectoryExists(location_) && !base::CreateDirectory(location_) && + location_ != base::FilePath("/dev/null")) + PLOG(FATAL) << "unable to create output directory"; + if (!base::PathIsWritable(location_)) + PLOG(FATAL) << "unable to write to output location"; +} + +int32_t HeadlessWindowManager::AddWindow(HeadlessWindow* window) { + return windows_.Add(window); +} + +void HeadlessWindowManager::RemoveWindow(int32_t window_id, + HeadlessWindow* window) { + DCHECK_EQ(window, windows_.Lookup(window_id)); + windows_.Remove(window_id); +} + +HeadlessWindow* HeadlessWindowManager::GetWindow(int32_t window_id) { + return windows_.Lookup(window_id); +} + +base::FilePath HeadlessWindowManager::base_path() const { + return location_; +} + +} // namespace ui diff --git a/ui/ozone/platform/headless/headless_window_manager.h b/ui/ozone/platform/headless/headless_window_manager.h new file mode 100644 index 0000000..f2710bc --- /dev/null +++ b/ui/ozone/platform/headless/headless_window_manager.h @@ -0,0 +1,51 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_OZONE_PLATFORM_HEADLESS_HEADLESS_WINDOW_MANAGER_H_ +#define UI_OZONE_PLATFORM_HEADLESS_HEADLESS_WINDOW_MANAGER_H_ + +#include "base/files/file_path.h" +#include "base/id_map.h" +#include "base/macros.h" +#include "base/memory/scoped_ptr.h" +#include "base/threading/thread_checker.h" +#include "ui/gfx/native_widget_types.h" +#include "ui/ozone/public/surface_factory_ozone.h" + +namespace ui { + +class HeadlessWindow; + +class HeadlessWindowManager { + public: + explicit HeadlessWindowManager(const base::FilePath& dump_location); + ~HeadlessWindowManager(); + + // Initialize (mainly check that we have a place to write output to). + void Initialize(); + + // Register a new window. Returns the window id. + int32_t AddWindow(HeadlessWindow* window); + + // Remove a window. + void RemoveWindow(int32_t window_id, HeadlessWindow* window); + + // Find a window object by id; + HeadlessWindow* GetWindow(int32_t window_id); + + // User-supplied path for images. + base::FilePath base_path() const; + + private: + base::FilePath location_; + + IDMap windows_; + base::ThreadChecker thread_checker_; + + DISALLOW_COPY_AND_ASSIGN(HeadlessWindowManager); +}; + +} // namespace ui + +#endif // UI_OZONE_PLATFORM_HEADLESS_HEADLESS_WINDOW_MANAGER_H_ diff --git a/ui/ozone/platform/headless/ozone_platform_headless.cc b/ui/ozone/platform/headless/ozone_platform_headless.cc new file mode 100644 index 0000000..0fc1f19 --- /dev/null +++ b/ui/ozone/platform/headless/ozone_platform_headless.cc @@ -0,0 +1,130 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/ozone/platform/headless/ozone_platform_headless.h" + +#include "base/command_line.h" +#include "base/files/file_path.h" +#include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" +#include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" +#include "ui/events/ozone/layout/stub/stub_keyboard_layout_engine.h" +#include "ui/events/platform/platform_event_source.h" +#include "ui/ozone/common/native_display_delegate_ozone.h" +#include "ui/ozone/common/stub_overlay_manager.h" +#include "ui/ozone/platform/headless/headless_surface_factory.h" +#include "ui/ozone/platform/headless/headless_window.h" +#include "ui/ozone/platform/headless/headless_window_manager.h" +#include "ui/ozone/public/cursor_factory_ozone.h" +#include "ui/ozone/public/gpu_platform_support.h" +#include "ui/ozone/public/gpu_platform_support_host.h" +#include "ui/ozone/public/input_controller.h" +#include "ui/ozone/public/ozone_platform.h" +#include "ui/ozone/public/ozone_switches.h" +#include "ui/ozone/public/system_input_injector.h" + +namespace ui { + +namespace { + +// A headless implementation of PlatformEventSource that we can instantiate to +// make +// sure that the PlatformEventSource has an instance while in unit tests. +class HeadlessPlatformEventSource : public ui::PlatformEventSource { + public: + HeadlessPlatformEventSource() {} + ~HeadlessPlatformEventSource() override {} + + private: + DISALLOW_COPY_AND_ASSIGN(HeadlessPlatformEventSource); +}; + +// OzonePlatform for headless mode +class OzonePlatformHeadless : public OzonePlatform { + public: + OzonePlatformHeadless(const base::FilePath& dump_file) + : file_path_(dump_file) {} + ~OzonePlatformHeadless() override {} + + // OzonePlatform: + ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override { + return surface_factory_.get(); + } + OverlayManagerOzone* GetOverlayManager() override { + return overlay_manager_.get(); + } + CursorFactoryOzone* GetCursorFactoryOzone() override { + return cursor_factory_ozone_.get(); + } + InputController* GetInputController() override { + return input_controller_.get(); + } + GpuPlatformSupport* GetGpuPlatformSupport() override { + return gpu_platform_support_.get(); + } + GpuPlatformSupportHost* GetGpuPlatformSupportHost() override { + return gpu_platform_support_host_.get(); + } + scoped_ptr CreateSystemInputInjector() override { + return nullptr; // no input injection support. + } + scoped_ptr CreatePlatformWindow( + PlatformWindowDelegate* delegate, + const gfx::Rect& bounds) override { + return make_scoped_ptr( + new HeadlessWindow(delegate, window_manager_.get(), bounds)); + } + scoped_ptr CreateNativeDisplayDelegate() override { + return make_scoped_ptr(new NativeDisplayDelegateOzone()); + } + base::ScopedFD OpenClientNativePixmapDevice() const override { + return base::ScopedFD(); + } + + void InitializeUI() override { + window_manager_.reset(new HeadlessWindowManager(file_path_)); + window_manager_->Initialize(); + surface_factory_.reset(new HeadlessSurfaceFactory(window_manager_.get())); + // This unbreaks tests that create their own. + if (!PlatformEventSource::GetInstance()) + platform_event_source_.reset(new HeadlessPlatformEventSource); + KeyboardLayoutEngineManager::SetKeyboardLayoutEngine( + make_scoped_ptr(new StubKeyboardLayoutEngine())); + + overlay_manager_.reset(new StubOverlayManager()); + input_controller_ = CreateStubInputController(); + cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone); + gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost()); + } + + void InitializeGPU() override { + if (!surface_factory_) + surface_factory_.reset(new HeadlessSurfaceFactory()); + gpu_platform_support_.reset(CreateStubGpuPlatformSupport()); + } + + private: + scoped_ptr window_manager_; + scoped_ptr surface_factory_; + scoped_ptr platform_event_source_; + scoped_ptr cursor_factory_ozone_; + scoped_ptr input_controller_; + scoped_ptr gpu_platform_support_; + scoped_ptr gpu_platform_support_host_; + scoped_ptr overlay_manager_; + base::FilePath file_path_; + + DISALLOW_COPY_AND_ASSIGN(OzonePlatformHeadless); +}; + +} // namespace + +OzonePlatform* CreateOzonePlatformHeadless() { + base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); + base::FilePath location; + if (cmd->HasSwitch(switches::kOzoneDumpFile)) + location = cmd->GetSwitchValuePath(switches::kOzoneDumpFile); + return new OzonePlatformHeadless(location); +} + +} // namespace ui diff --git a/ui/ozone/platform/headless/ozone_platform_headless.h b/ui/ozone/platform/headless/ozone_platform_headless.h new file mode 100644 index 0000000..0c3e94c --- /dev/null +++ b/ui/ozone/platform/headless/ozone_platform_headless.h @@ -0,0 +1,17 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_OZONE_PLATFORM_HEADLESS_OZONE_PLATFORM_HEADLESS_H_ +#define UI_OZONE_PLATFORM_HEADLESS_OZONE_PLATFORM_HEADLESS_H_ + +namespace ui { + +class OzonePlatform; + +// Constructor hook for use in ozone_platform_list.cc +OzonePlatform* CreateOzonePlatformHeadless(); + +} // namespace ui + +#endif // UI_OZONE_PLATFORM_HEADLESS_OZONE_PLATFORM_HEADLESS_H_ diff --git a/ui/ozone/platform/test/BUILD.gn b/ui/ozone/platform/test/BUILD.gn deleted file mode 100644 index 2148d7b..0000000 --- a/ui/ozone/platform/test/BUILD.gn +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright 2014 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -source_set("test") { - sources = [ - "client_native_pixmap_factory_test.cc", - "client_native_pixmap_factory_test.h", - "ozone_platform_test.cc", - "ozone_platform_test.h", - "test_surface_factory.cc", - "test_surface_factory.h", - "test_window.cc", - "test_window.h", - "test_window_manager.cc", - "test_window_manager.h", - ] - - deps = [ - "//base", - "//skia", - "//ui/base", - "//ui/gfx/geometry", - "//ui/events/ozone:events_ozone_layout", - "//ui/events/platform", - ] -} diff --git a/ui/ozone/platform/test/DEPS b/ui/ozone/platform/test/DEPS deleted file mode 100644 index 41cd997..0000000 --- a/ui/ozone/platform/test/DEPS +++ /dev/null @@ -1,3 +0,0 @@ -include_rules = [ - "+third_party/skia/include", -] diff --git a/ui/ozone/platform/test/client_native_pixmap_factory_test.cc b/ui/ozone/platform/test/client_native_pixmap_factory_test.cc deleted file mode 100644 index 9a8e3e2..0000000 --- a/ui/ozone/platform/test/client_native_pixmap_factory_test.cc +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ui/ozone/platform/test/client_native_pixmap_factory_test.h" - -#include "ui/ozone/common/stub_client_native_pixmap_factory.h" - -namespace ui { - -ClientNativePixmapFactory* CreateClientNativePixmapFactoryTest() { - return CreateStubClientNativePixmapFactory(); -} - -} // namespace ui diff --git a/ui/ozone/platform/test/client_native_pixmap_factory_test.h b/ui/ozone/platform/test/client_native_pixmap_factory_test.h deleted file mode 100644 index ed2ead8..0000000 --- a/ui/ozone/platform/test/client_native_pixmap_factory_test.h +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef UI_OZONE_PLATFORM_TEST_CLIENT_NATIVE_PIXMAP_FACTORY_TEST_H_ -#define UI_OZONE_PLATFORM_TEST_CLIENT_NATIVE_PIXMAP_FACTORY_TEST_H_ - -namespace ui { - -class ClientNativePixmapFactory; - -// Constructor hook for use in constructor_list.cc -ClientNativePixmapFactory* CreateClientNativePixmapFactoryTest(); - -} // namespace ui - -#endif // UI_OZONE_PLATFORM_TEST_CLIENT_NATIVE_PIXMAP_FACTORY_TEST_H_ diff --git a/ui/ozone/platform/test/ozone_platform_test.cc b/ui/ozone/platform/test/ozone_platform_test.cc deleted file mode 100644 index ed69388..0000000 --- a/ui/ozone/platform/test/ozone_platform_test.cc +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ui/ozone/platform/test/ozone_platform_test.h" - -#include "base/command_line.h" -#include "base/files/file_path.h" -#include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" -#include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" -#include "ui/events/ozone/layout/stub/stub_keyboard_layout_engine.h" -#include "ui/events/platform/platform_event_source.h" -#include "ui/ozone/common/native_display_delegate_ozone.h" -#include "ui/ozone/common/stub_overlay_manager.h" -#include "ui/ozone/platform/test/test_surface_factory.h" -#include "ui/ozone/platform/test/test_window.h" -#include "ui/ozone/platform/test/test_window_manager.h" -#include "ui/ozone/public/cursor_factory_ozone.h" -#include "ui/ozone/public/gpu_platform_support.h" -#include "ui/ozone/public/gpu_platform_support_host.h" -#include "ui/ozone/public/input_controller.h" -#include "ui/ozone/public/ozone_platform.h" -#include "ui/ozone/public/ozone_switches.h" -#include "ui/ozone/public/system_input_injector.h" - -namespace ui { - -namespace { - -// A test implementation of PlatformEventSource that we can instantiate to make -// sure that the PlatformEventSource has an instance while in unit tests. -class TestPlatformEventSource : public ui::PlatformEventSource { - public: - TestPlatformEventSource() {} - ~TestPlatformEventSource() override {} - - private: - DISALLOW_COPY_AND_ASSIGN(TestPlatformEventSource); -}; - -// OzonePlatform for testing -// -// This platform dumps images to a file for testing purposes. -class OzonePlatformTest : public OzonePlatform { - public: - OzonePlatformTest(const base::FilePath& dump_file) : file_path_(dump_file) {} - ~OzonePlatformTest() override {} - - // OzonePlatform: - ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override { - return surface_factory_.get(); - } - OverlayManagerOzone* GetOverlayManager() override { - return overlay_manager_.get(); - } - CursorFactoryOzone* GetCursorFactoryOzone() override { - return cursor_factory_ozone_.get(); - } - InputController* GetInputController() override { - return input_controller_.get(); - } - GpuPlatformSupport* GetGpuPlatformSupport() override { - return gpu_platform_support_.get(); - } - GpuPlatformSupportHost* GetGpuPlatformSupportHost() override { - return gpu_platform_support_host_.get(); - } - scoped_ptr CreateSystemInputInjector() override { - return nullptr; // no input injection support. - } - scoped_ptr CreatePlatformWindow( - PlatformWindowDelegate* delegate, - const gfx::Rect& bounds) override { - return make_scoped_ptr( - new TestWindow(delegate, window_manager_.get(), bounds)); - } - scoped_ptr CreateNativeDisplayDelegate() override { - return make_scoped_ptr(new NativeDisplayDelegateOzone()); - } - base::ScopedFD OpenClientNativePixmapDevice() const override { - return base::ScopedFD(); - } - - void InitializeUI() override { - window_manager_.reset(new TestWindowManager(file_path_)); - window_manager_->Initialize(); - surface_factory_.reset(new TestSurfaceFactory(window_manager_.get())); - // This unbreaks tests that create their own. - if (!PlatformEventSource::GetInstance()) - platform_event_source_.reset(new TestPlatformEventSource); - KeyboardLayoutEngineManager::SetKeyboardLayoutEngine( - make_scoped_ptr(new StubKeyboardLayoutEngine())); - - overlay_manager_.reset(new StubOverlayManager()); - input_controller_ = CreateStubInputController(); - cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone); - gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost()); - } - - void InitializeGPU() override { - if (!surface_factory_) - surface_factory_.reset(new TestSurfaceFactory()); - gpu_platform_support_.reset(CreateStubGpuPlatformSupport()); - } - - private: - scoped_ptr window_manager_; - scoped_ptr surface_factory_; - scoped_ptr platform_event_source_; - scoped_ptr cursor_factory_ozone_; - scoped_ptr input_controller_; - scoped_ptr gpu_platform_support_; - scoped_ptr gpu_platform_support_host_; - scoped_ptr overlay_manager_; - base::FilePath file_path_; - - DISALLOW_COPY_AND_ASSIGN(OzonePlatformTest); -}; - -} // namespace - -OzonePlatform* CreateOzonePlatformTest() { - base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); - base::FilePath location; - if (cmd->HasSwitch(switches::kOzoneDumpFile)) - location = cmd->GetSwitchValuePath(switches::kOzoneDumpFile); - return new OzonePlatformTest(location); -} - -} // namespace ui diff --git a/ui/ozone/platform/test/ozone_platform_test.h b/ui/ozone/platform/test/ozone_platform_test.h deleted file mode 100644 index fb25fd6..0000000 --- a/ui/ozone/platform/test/ozone_platform_test.h +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef UI_OZONE_PLATFORM_TEST_OZONE_PLATFORM_TEST_H_ -#define UI_OZONE_PLATFORM_TEST_OZONE_PLATFORM_TEST_H_ - -namespace ui { - -class OzonePlatform; - -// Constructor hook for use in ozone_platform_list.cc -OzonePlatform* CreateOzonePlatformTest(); - -} // namespace ui - -#endif // UI_OZONE_PLATFORM_TEST_OZONE_PLATFORM_TEST_H_ diff --git a/ui/ozone/platform/test/test.gypi b/ui/ozone/platform/test/test.gypi deleted file mode 100644 index 6b2794b..0000000 --- a/ui/ozone/platform/test/test.gypi +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright 2014 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -{ - 'variables': { - 'internal_ozone_platform_deps': [ - 'ozone_platform_test', - ], - 'internal_ozone_platforms': [ - 'test' - ], - }, - 'targets': [ - { - 'target_name': 'ozone_platform_test', - 'type': 'static_library', - 'defines': [ - 'OZONE_IMPLEMENTATION', - ], - 'dependencies': [ - '../../base/base.gyp:base', - '../base/ui_base.gyp:ui_base', - '../events/events.gyp:events', - '../events/ozone/events_ozone.gyp:events_ozone_layout', - '../events/platform/events_platform.gyp:events_platform', - '../gfx/gfx.gyp:gfx', - ], - 'sources': [ - 'client_native_pixmap_factory_test.cc', - 'client_native_pixmap_factory_test.h', - 'ozone_platform_test.cc', - 'ozone_platform_test.h', - 'test_surface_factory.cc', - 'test_surface_factory.h', - 'test_window.cc', - 'test_window.h', - 'test_window_manager.cc', - 'test_window_manager.h', - ], - }, - ], -} diff --git a/ui/ozone/platform/test/test_surface_factory.cc b/ui/ozone/platform/test/test_surface_factory.cc deleted file mode 100644 index b513441..0000000 --- a/ui/ozone/platform/test/test_surface_factory.cc +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ui/ozone/platform/test/test_surface_factory.h" - -#include "base/bind.h" -#include "base/files/file_util.h" -#include "base/location.h" -#include "base/stl_util.h" -#include "base/threading/worker_pool.h" -#include "third_party/skia/include/core/SkCanvas.h" -#include "third_party/skia/include/core/SkSurface.h" -#include "ui/gfx/codec/png_codec.h" -#include "ui/gfx/skia_util.h" -#include "ui/gfx/vsync_provider.h" -#include "ui/ozone/platform/test/test_window.h" -#include "ui/ozone/platform/test/test_window_manager.h" -#include "ui/ozone/public/surface_ozone_canvas.h" - -namespace ui { - -namespace { - -void WriteDataToFile(const base::FilePath& location, const SkBitmap& bitmap) { - DCHECK(!location.empty()); - std::vector png_data; - gfx::PNGCodec::FastEncodeBGRASkBitmap(bitmap, true, &png_data); - base::WriteFile(location, - reinterpret_cast(vector_as_array(&png_data)), - png_data.size()); -} - -class FileSurface : public SurfaceOzoneCanvas { - public: - FileSurface(const base::FilePath& location) : location_(location) {} - ~FileSurface() override {} - - // SurfaceOzoneCanvas overrides: - void ResizeCanvas(const gfx::Size& viewport_size) override { - surface_ = skia::AdoptRef(SkSurface::NewRaster(SkImageInfo::MakeN32Premul( - viewport_size.width(), viewport_size.height()))); - } - skia::RefPtr GetSurface() override { return surface_; } - void PresentCanvas(const gfx::Rect& damage) override { - if (location_.empty()) - return; - SkBitmap bitmap; - bitmap.setInfo(surface_->getCanvas()->imageInfo()); - - // TODO(dnicoara) Use SkImage instead to potentially avoid a copy. - // See crbug.com/361605 for details. - if (surface_->getCanvas()->readPixels(&bitmap, 0, 0)) { - base::WorkerPool::PostTask( - FROM_HERE, base::Bind(&WriteDataToFile, location_, bitmap), true); - } - } - scoped_ptr CreateVSyncProvider() override { - return nullptr; - } - - private: - base::FilePath location_; - skia::RefPtr surface_; -}; - -} // namespace - -TestSurfaceFactory::TestSurfaceFactory() : TestSurfaceFactory(nullptr) {} - -TestSurfaceFactory::TestSurfaceFactory(TestWindowManager* window_manager) - : window_manager_(window_manager) {} - -TestSurfaceFactory::~TestSurfaceFactory() {} - -scoped_ptr TestSurfaceFactory::CreateCanvasForWidget( - gfx::AcceleratedWidget widget) { - TestWindow* window = window_manager_->GetWindow(widget); - return make_scoped_ptr(new FileSurface(window->path())); -} - -bool TestSurfaceFactory::LoadEGLGLES2Bindings( - AddGLLibraryCallback add_gl_library, - SetGLGetProcAddressProcCallback set_gl_get_proc_address) { - return false; -} - -} // namespace ui diff --git a/ui/ozone/platform/test/test_surface_factory.h b/ui/ozone/platform/test/test_surface_factory.h deleted file mode 100644 index 98002ec..0000000 --- a/ui/ozone/platform/test/test_surface_factory.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef UI_OZONE_PLATFORM_TEST_TEST_SURFACE_FACTORY_H_ -#define UI_OZONE_PLATFORM_TEST_TEST_SURFACE_FACTORY_H_ - -#include "ui/ozone/public/surface_factory_ozone.h" - -namespace ui { - -class TestWindowManager; - -class TestSurfaceFactory : public SurfaceFactoryOzone { - public: - TestSurfaceFactory(); - explicit TestSurfaceFactory(TestWindowManager* window_manager); - ~TestSurfaceFactory() override; - - // SurfaceFactoryOzone: - scoped_ptr CreateCanvasForWidget( - gfx::AcceleratedWidget w) override; - bool LoadEGLGLES2Bindings( - AddGLLibraryCallback add_gl_library, - SetGLGetProcAddressProcCallback set_gl_get_proc_address) override; - - private: - TestWindowManager* window_manager_; - - DISALLOW_COPY_AND_ASSIGN(TestSurfaceFactory); -}; - -} // namespace ui - -#endif // UI_OZONE_PLATFORM_TEST_TEST_SURFACE_FACTORY_H_ diff --git a/ui/ozone/platform/test/test_window.cc b/ui/ozone/platform/test/test_window.cc deleted file mode 100644 index 8cbe171..0000000 --- a/ui/ozone/platform/test/test_window.cc +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ui/ozone/platform/test/test_window.h" - -#include - -#include "base/files/file_path.h" -#include "base/strings/string_number_conversions.h" -#include "ui/events/platform/platform_event_source.h" -#include "ui/ozone/platform/test/test_window_manager.h" -#include "ui/platform_window/platform_window_delegate.h" - -namespace ui { - -TestWindow::TestWindow(PlatformWindowDelegate* delegate, - TestWindowManager* manager, - const gfx::Rect& bounds) - : delegate_(delegate), manager_(manager), bounds_(bounds) { - widget_ = manager_->AddWindow(this); - delegate_->OnAcceleratedWidgetAvailable(widget_, 1.f); -} - -TestWindow::~TestWindow() { - manager_->RemoveWindow(widget_, this); -} - -base::FilePath TestWindow::path() { - base::FilePath base_path = manager_->base_path(); - if (base_path.empty() || base_path == base::FilePath("/dev/null")) - return base_path; - - // Disambiguate multiple window output files with the window id. - return base_path.Append(base::IntToString(widget_)); -} - -gfx::Rect TestWindow::GetBounds() { - return bounds_; -} - -void TestWindow::SetBounds(const gfx::Rect& bounds) { - bounds_ = bounds; - delegate_->OnBoundsChanged(bounds); -} - -void TestWindow::SetTitle(const base::string16& title) { -} - -void TestWindow::Show() { -} - -void TestWindow::Hide() { -} - -void TestWindow::Close() { -} - -void TestWindow::SetCapture() { -} - -void TestWindow::ReleaseCapture() { -} - -void TestWindow::ToggleFullscreen() { -} - -void TestWindow::Maximize() { -} - -void TestWindow::Minimize() { -} - -void TestWindow::Restore() { -} - -void TestWindow::SetCursor(PlatformCursor cursor) { -} - -void TestWindow::MoveCursorTo(const gfx::Point& location) { -} - -void TestWindow::ConfineCursorToBounds(const gfx::Rect& bounds) { -} - -PlatformImeController* TestWindow::GetPlatformImeController() { - return nullptr; -} - -} // namespace ui diff --git a/ui/ozone/platform/test/test_window.h b/ui/ozone/platform/test/test_window.h deleted file mode 100644 index 0dacf33..0000000 --- a/ui/ozone/platform/test/test_window.h +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef UI_OZONE_PLATFORM_TEST_TEST_WINDOW_H_ -#define UI_OZONE_PLATFORM_TEST_TEST_WINDOW_H_ - -#include "base/files/file_path.h" -#include "ui/gfx/geometry/rect.h" -#include "ui/gfx/native_widget_types.h" -#include "ui/platform_window/platform_window.h" - -namespace ui { - -class PlatformWindowDelegate; -class TestWindowManager; - -class TestWindow : public PlatformWindow { - public: - TestWindow(PlatformWindowDelegate* delegate, - TestWindowManager* manager, - const gfx::Rect& bounds); - ~TestWindow() override; - - // Path for image file for this window. - base::FilePath path(); - - // PlatformWindow: - gfx::Rect GetBounds() override; - void SetBounds(const gfx::Rect& bounds) override; - void SetTitle(const base::string16& title) override; - void Show() override; - void Hide() override; - void Close() override; - void SetCapture() override; - void ReleaseCapture() override; - void ToggleFullscreen() override; - void Maximize() override; - void Minimize() override; - void Restore() override; - void SetCursor(PlatformCursor cursor) override; - void MoveCursorTo(const gfx::Point& location) override; - void ConfineCursorToBounds(const gfx::Rect& bounds) override; - PlatformImeController* GetPlatformImeController() override; - - private: - PlatformWindowDelegate* delegate_; - TestWindowManager* manager_; - gfx::Rect bounds_; - gfx::AcceleratedWidget widget_; - - DISALLOW_COPY_AND_ASSIGN(TestWindow); -}; - -} // namespace ui - -#endif // UI_OZONE_PLATFORM_TEST_TEST_WINDOW_H_ diff --git a/ui/ozone/platform/test/test_window_manager.cc b/ui/ozone/platform/test/test_window_manager.cc deleted file mode 100644 index 1887c62..0000000 --- a/ui/ozone/platform/test/test_window_manager.cc +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ui/ozone/platform/test/test_window_manager.h" - -#include "base/files/file_util.h" -#include "base/location.h" - -namespace ui { - -TestWindowManager::TestWindowManager(const base::FilePath& dump_location) - : location_(dump_location) { -} - -TestWindowManager::~TestWindowManager() { - DCHECK(thread_checker_.CalledOnValidThread()); -} - -void TestWindowManager::Initialize() { - if (location_.empty()) - return; - if (!DirectoryExists(location_) && !base::CreateDirectory(location_) && - location_ != base::FilePath("/dev/null")) - PLOG(FATAL) << "unable to create output directory"; - if (!base::PathIsWritable(location_)) - PLOG(FATAL) << "unable to write to output location"; -} - -int32_t TestWindowManager::AddWindow(TestWindow* window) { - return windows_.Add(window); -} - -void TestWindowManager::RemoveWindow(int32_t window_id, TestWindow* window) { - DCHECK_EQ(window, windows_.Lookup(window_id)); - windows_.Remove(window_id); -} - -TestWindow* TestWindowManager::GetWindow(int32_t window_id) { - return windows_.Lookup(window_id); -} - -base::FilePath TestWindowManager::base_path() const { - return location_; -} - -} // namespace ui diff --git a/ui/ozone/platform/test/test_window_manager.h b/ui/ozone/platform/test/test_window_manager.h deleted file mode 100644 index b7adc14..0000000 --- a/ui/ozone/platform/test/test_window_manager.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef UI_OZONE_PLATFORM_TEST_TEST_WINDOW_MANAGER_H_ -#define UI_OZONE_PLATFORM_TEST_TEST_WINDOW_MANAGER_H_ - -#include "base/files/file_path.h" -#include "base/id_map.h" -#include "base/memory/scoped_ptr.h" -#include "base/threading/thread_checker.h" -#include "ui/gfx/native_widget_types.h" -#include "ui/ozone/public/surface_factory_ozone.h" - -namespace ui { - -class TestWindow; - -class TestWindowManager { - public: - explicit TestWindowManager(const base::FilePath& dump_location); - ~TestWindowManager(); - - // Initialize (mainly check that we have a place to write output to). - void Initialize(); - - // Register a new window. Returns the window id. - int32_t AddWindow(TestWindow* window); - - // Remove a window. - void RemoveWindow(int32_t window_id, TestWindow* window); - - // Find a window object by id; - TestWindow* GetWindow(int32_t window_id); - - // User-supplied path for images. - base::FilePath base_path() const; - - private: - base::FilePath location_; - - IDMap windows_; - base::ThreadChecker thread_checker_; - - DISALLOW_COPY_AND_ASSIGN(TestWindowManager); -}; - -} // namespace ui - -#endif // UI_OZONE_PLATFORM_TEST_TEST_WINDOW_MANAGER_H_ -- cgit v1.1