Commit a9c120b0 authored by varkha@chromium.org's avatar varkha@chromium.org

Changes test ozone platform to not produce any output when --ozone-dump-file...

Changes test ozone platform to not produce any output when --ozone-dump-file is not specified. Also modifies the test ozone platform to not implement any event dispatch.

BUG=178543

Review URL: https://codereview.chromium.org/419993003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288132 0039d316-1c4b-4281-b951-d872f2087c98
parent ea4a89da
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "ui/events/ozone/device/device_manager.h"
#include "ui/ozone/platform/test/test_cursor_factory.h" #include "ui/ozone/platform/test/test_cursor_factory.h"
#include "ui/ozone/platform/test/test_event_factory.h" #include "ui/ozone/platform/test/test_event_factory.h"
#include "ui/ozone/platform/test/test_window.h" #include "ui/ozone/platform/test/test_window.h"
...@@ -70,7 +69,6 @@ class OzonePlatformTest : public OzonePlatform { ...@@ -70,7 +69,6 @@ class OzonePlatformTest : public OzonePlatform {
#endif #endif
virtual void InitializeUI() OVERRIDE { virtual void InitializeUI() OVERRIDE {
device_manager_ = CreateDeviceManager();
window_manager_.reset(new TestWindowManager(file_path_)); window_manager_.reset(new TestWindowManager(file_path_));
window_manager_->Initialize(); window_manager_->Initialize();
event_factory_ozone_.reset(new TestEventFactory()); event_factory_ozone_.reset(new TestEventFactory());
...@@ -83,7 +81,6 @@ class OzonePlatformTest : public OzonePlatform { ...@@ -83,7 +81,6 @@ class OzonePlatformTest : public OzonePlatform {
} }
private: private:
scoped_ptr<DeviceManager> device_manager_;
scoped_ptr<TestWindowManager> window_manager_; scoped_ptr<TestWindowManager> window_manager_;
scoped_ptr<TestEventFactory> event_factory_ozone_; scoped_ptr<TestEventFactory> event_factory_ozone_;
scoped_ptr<CursorFactoryOzone> cursor_factory_ozone_; scoped_ptr<CursorFactoryOzone> cursor_factory_ozone_;
...@@ -98,7 +95,7 @@ class OzonePlatformTest : public OzonePlatform { ...@@ -98,7 +95,7 @@ class OzonePlatformTest : public OzonePlatform {
OzonePlatform* CreateOzonePlatformTest() { OzonePlatform* CreateOzonePlatformTest() {
CommandLine* cmd = CommandLine::ForCurrentProcess(); CommandLine* cmd = CommandLine::ForCurrentProcess();
base::FilePath location = base::FilePath("/dev/null"); base::FilePath location;
if (cmd->HasSwitch(switches::kOzoneDumpFile)) if (cmd->HasSwitch(switches::kOzoneDumpFile))
location = cmd->GetSwitchValuePath(switches::kOzoneDumpFile); location = cmd->GetSwitchValuePath(switches::kOzoneDumpFile);
return new OzonePlatformTest(location); return new OzonePlatformTest(location);
......
...@@ -19,19 +19,16 @@ TestWindow::TestWindow(PlatformWindowDelegate* delegate, ...@@ -19,19 +19,16 @@ TestWindow::TestWindow(PlatformWindowDelegate* delegate,
const gfx::Rect& bounds) const gfx::Rect& bounds)
: delegate_(delegate), manager_(manager), bounds_(bounds) { : delegate_(delegate), manager_(manager), bounds_(bounds) {
widget_ = manager_->AddWindow(this); widget_ = manager_->AddWindow(this);
ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this);
delegate_->OnAcceleratedWidgetAvailable(widget_); delegate_->OnAcceleratedWidgetAvailable(widget_);
} }
TestWindow::~TestWindow() { TestWindow::~TestWindow() {
ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this);
manager_->RemoveWindow(widget_, this); manager_->RemoveWindow(widget_, this);
} }
base::FilePath TestWindow::path() { base::FilePath TestWindow::path() {
base::FilePath base_path = manager_->base_path(); base::FilePath base_path = manager_->base_path();
if (base_path.empty() || base_path == base::FilePath("/dev/null"))
if (base_path == base::FilePath("/dev/null"))
return base_path; return base_path;
// Disambiguate multiple window output files with the window id. // Disambiguate multiple window output files with the window id.
...@@ -80,14 +77,4 @@ void TestWindow::SetCursor(PlatformCursor cursor) { ...@@ -80,14 +77,4 @@ void TestWindow::SetCursor(PlatformCursor cursor) {
void TestWindow::MoveCursorTo(const gfx::Point& location) { void TestWindow::MoveCursorTo(const gfx::Point& location) {
} }
bool TestWindow::CanDispatchEvent(const ui::PlatformEvent& ne) {
return true;
}
uint32_t TestWindow::DispatchEvent(const ui::PlatformEvent& ne) {
ui::Event* event = static_cast<ui::Event*>(ne);
delegate_->DispatchEvent(event);
return ui::POST_DISPATCH_STOP_PROPAGATION;
}
} // namespace ui } // namespace ui
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#define UI_OZONE_PLATFORM_TEST_TEST_WINDOW_H_ #define UI_OZONE_PLATFORM_TEST_TEST_WINDOW_H_
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "ui/events/platform/platform_event_dispatcher.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
#include "ui/gfx/native_widget_types.h" #include "ui/gfx/native_widget_types.h"
#include "ui/platform_window/platform_window.h" #include "ui/platform_window/platform_window.h"
...@@ -16,7 +15,7 @@ namespace ui { ...@@ -16,7 +15,7 @@ namespace ui {
class PlatformWindowDelegate; class PlatformWindowDelegate;
class TestWindowManager; class TestWindowManager;
class TestWindow : public PlatformWindow, public PlatformEventDispatcher { class TestWindow : public PlatformWindow {
public: public:
TestWindow(PlatformWindowDelegate* delegate, TestWindow(PlatformWindowDelegate* delegate,
TestWindowManager* manager, TestWindowManager* manager,
...@@ -41,10 +40,6 @@ class TestWindow : public PlatformWindow, public PlatformEventDispatcher { ...@@ -41,10 +40,6 @@ class TestWindow : public PlatformWindow, public PlatformEventDispatcher {
virtual void SetCursor(PlatformCursor cursor) OVERRIDE; virtual void SetCursor(PlatformCursor cursor) OVERRIDE;
virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE; virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE;
// PlatformEventDispatcher:
virtual bool CanDispatchEvent(const PlatformEvent& event) OVERRIDE;
virtual uint32_t DispatchEvent(const PlatformEvent& event) OVERRIDE;
private: private:
PlatformWindowDelegate* delegate_; PlatformWindowDelegate* delegate_;
TestWindowManager* manager_; TestWindowManager* manager_;
......
...@@ -21,6 +21,7 @@ namespace ui { ...@@ -21,6 +21,7 @@ namespace ui {
namespace { namespace {
void WriteDataToFile(const base::FilePath& location, const SkBitmap& bitmap) { void WriteDataToFile(const base::FilePath& location, const SkBitmap& bitmap) {
DCHECK(!location.empty());
std::vector<unsigned char> png_data; std::vector<unsigned char> png_data;
gfx::PNGCodec::FastEncodeBGRASkBitmap(bitmap, true, &png_data); gfx::PNGCodec::FastEncodeBGRASkBitmap(bitmap, true, &png_data);
base::WriteFile(location, base::WriteFile(location,
...@@ -42,6 +43,8 @@ class FileSurface : public SurfaceOzoneCanvas { ...@@ -42,6 +43,8 @@ class FileSurface : public SurfaceOzoneCanvas {
return skia::SharePtr(surface_->getCanvas()); return skia::SharePtr(surface_->getCanvas());
} }
virtual void PresentCanvas(const gfx::Rect& damage) OVERRIDE { virtual void PresentCanvas(const gfx::Rect& damage) OVERRIDE {
if (location_.empty())
return;
SkBitmap bitmap; SkBitmap bitmap;
bitmap.setInfo(surface_->getCanvas()->imageInfo()); bitmap.setInfo(surface_->getCanvas()->imageInfo());
...@@ -71,6 +74,8 @@ TestWindowManager::~TestWindowManager() { ...@@ -71,6 +74,8 @@ TestWindowManager::~TestWindowManager() {
} }
void TestWindowManager::Initialize() { void TestWindowManager::Initialize() {
if (location_.empty())
return;
if (!DirectoryExists(location_) && !base::CreateDirectory(location_) && if (!DirectoryExists(location_) && !base::CreateDirectory(location_) &&
location_ != base::FilePath("/dev/null")) location_ != base::FilePath("/dev/null"))
PLOG(FATAL) << "unable to create output directory"; PLOG(FATAL) << "unable to create output directory";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment