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

Side by Side Diff: ui/ozone/platform/test/test_window_manager.cc

Issue 377973005: ozone: test: Convert to PlatformWindow (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add dcheck Created 6 years, 5 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
« no previous file with comments | « ui/ozone/platform/test/test_window_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ui/ozone/platform/test/file_surface_factory.h" 5 #include "ui/ozone/platform/test/test_window_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "base/threading/worker_pool.h" 11 #include "base/threading/worker_pool.h"
12 #include "third_party/skia/include/core/SkCanvas.h" 12 #include "third_party/skia/include/core/SkCanvas.h"
13 #include "third_party/skia/include/core/SkSurface.h" 13 #include "third_party/skia/include/core/SkSurface.h"
14 #include "ui/gfx/codec/png_codec.h" 14 #include "ui/gfx/codec/png_codec.h"
15 #include "ui/gfx/skia_util.h" 15 #include "ui/gfx/skia_util.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 return scoped_ptr<gfx::VSyncProvider>(); 56 return scoped_ptr<gfx::VSyncProvider>();
57 } 57 }
58 58
59 private: 59 private:
60 base::FilePath location_; 60 base::FilePath location_;
61 skia::RefPtr<SkSurface> surface_; 61 skia::RefPtr<SkSurface> surface_;
62 }; 62 };
63 63
64 } // namespace 64 } // namespace
65 65
66 FileSurfaceFactory::FileSurfaceFactory(const base::FilePath& dump_location) 66 TestWindowManager::TestWindowManager(const base::FilePath& dump_location)
67 : location_(dump_location) { 67 : location_(dump_location) {
68 CHECK(!base::DirectoryExists(location_)) << "Location cannot be a directory ("
69 << location_.value() << ")";
70 CHECK(!base::PathExists(location_) || base::PathIsWritable(location_));
71 } 68 }
72 69
73 FileSurfaceFactory::~FileSurfaceFactory() { 70 TestWindowManager::~TestWindowManager() {
74 } 71 }
75 72
76 SurfaceFactoryOzone::HardwareState FileSurfaceFactory::InitializeHardware() { 73 void TestWindowManager::Initialize() {
74 if (!DirectoryExists(location_) && !base::CreateDirectory(location_) &&
75 location_ != base::FilePath("/dev/null"))
76 PLOG(FATAL) << "unable to create output directory";
77 if (!base::PathIsWritable(location_))
78 PLOG(FATAL) << "unable to write to output location";
79 }
80
81 int32_t TestWindowManager::AddWindow(TestWindow* window) {
82 return windows_.Add(window);
83 }
84
85 void TestWindowManager::RemoveWindow(int32_t window_id, TestWindow* window) {
86 DCHECK_EQ(window, windows_.Lookup(window_id));
87 windows_.Remove(window_id);
88 }
89
90 base::FilePath TestWindowManager::base_path() const {
91 return location_;
92 }
93
94 SurfaceFactoryOzone::HardwareState TestWindowManager::InitializeHardware() {
77 return INITIALIZED; 95 return INITIALIZED;
78 } 96 }
79 97
80 void FileSurfaceFactory::ShutdownHardware() { 98 void TestWindowManager::ShutdownHardware() {
81 } 99 }
82 100
83 gfx::AcceleratedWidget FileSurfaceFactory::GetAcceleratedWidget() { 101 gfx::AcceleratedWidget TestWindowManager::GetAcceleratedWidget() {
84 return 1; 102 NOTREACHED();
103 return -1;
85 } 104 }
86 105
87 scoped_ptr<SurfaceOzoneCanvas> FileSurfaceFactory::CreateCanvasForWidget( 106 scoped_ptr<SurfaceOzoneCanvas> TestWindowManager::CreateCanvasForWidget(
88 gfx::AcceleratedWidget w) { 107 gfx::AcceleratedWidget widget) {
89 return make_scoped_ptr<SurfaceOzoneCanvas>(new FileSurface(location_)); 108 TestWindow* window = windows_.Lookup(widget);
109 DCHECK(window);
110 return make_scoped_ptr<SurfaceOzoneCanvas>(new FileSurface(window->path()));
90 } 111 }
91 112
92 bool FileSurfaceFactory::LoadEGLGLES2Bindings( 113 bool TestWindowManager::LoadEGLGLES2Bindings(
93 AddGLLibraryCallback add_gl_library, 114 AddGLLibraryCallback add_gl_library,
94 SetGLGetProcAddressProcCallback set_gl_get_proc_address) { 115 SetGLGetProcAddressProcCallback set_gl_get_proc_address) {
95 return false; 116 return false;
96 } 117 }
97 118
98 } // namespace ui 119 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/test/test_window_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698