Chromium Code Reviews| Index: ui/ozone/platform/test/test_window_manager.cc |
| diff --git a/ui/ozone/platform/test/test_window_manager.cc b/ui/ozone/platform/test/test_window_manager.cc |
| index 8e6e4b02b1a0e3640618e9d1ff03e3b2fdcfa193..e84297c3ea884b89aa4c68164132004dd8bd212d 100644 |
| --- a/ui/ozone/platform/test/test_window_manager.cc |
| +++ b/ui/ozone/platform/test/test_window_manager.cc |
| @@ -21,6 +21,7 @@ namespace ui { |
| namespace { |
| void WriteDataToFile(const base::FilePath& location, const SkBitmap& bitmap) { |
| + DCHECK(!location.empty()); |
| std::vector<unsigned char> png_data; |
| gfx::PNGCodec::FastEncodeBGRASkBitmap(bitmap, true, &png_data); |
| base::WriteFile(location, |
| @@ -42,6 +43,8 @@ class FileSurface : public SurfaceOzoneCanvas { |
| return skia::SharePtr(surface_->getCanvas()); |
| } |
| virtual void PresentCanvas(const gfx::Rect& damage) OVERRIDE { |
| + if (location_.empty()) |
| + return; |
| SkBitmap bitmap; |
| bitmap.setInfo(surface_->getCanvas()->imageInfo()); |
| @@ -71,6 +74,8 @@ TestWindowManager::~TestWindowManager() { |
| } |
| 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"; |
| @@ -79,10 +84,14 @@ void TestWindowManager::Initialize() { |
| } |
| int32_t TestWindowManager::AddWindow(TestWindow* window) { |
| + if (location_.empty()) |
| + return 1; |
| return windows_.Add(window); |
| } |
| void TestWindowManager::RemoveWindow(int32_t window_id, TestWindow* window) { |
| + if (location_.empty()) |
| + return; |
| DCHECK_EQ(window, windows_.Lookup(window_id)); |
| windows_.Remove(window_id); |
| } |
| @@ -93,6 +102,10 @@ base::FilePath TestWindowManager::base_path() const { |
| scoped_ptr<SurfaceOzoneCanvas> TestWindowManager::CreateCanvasForWidget( |
| gfx::AcceleratedWidget widget) { |
| + if (location_.empty()) { |
|
dnicoara
2014/07/31 02:51:31
There is no reason to complicate the code with the
spang
2014/07/31 16:04:01
I think we need the one in Initialize() and in Pre
dnicoara
2014/07/31 16:09:23
The one in CreateCanvasForWidget shouldn't be need
varkha
2014/08/07 00:17:10
Acknowledged.
varkha
2014/08/07 00:17:10
Done.
varkha
2014/08/07 00:17:11
Done.
|
| + return make_scoped_ptr<SurfaceOzoneCanvas>( |
| + new FileSurface(base::FilePath())); |
| + } |
| TestWindow* window = windows_.Lookup(widget); |
| DCHECK(window); |
| return make_scoped_ptr<SurfaceOzoneCanvas>(new FileSurface(window->path())); |