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 @@
#include "base/command_line.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_event_factory.h"
#include "ui/ozone/platform/test/test_window.h"
......@@ -70,7 +69,6 @@ class OzonePlatformTest : public OzonePlatform {
#endif
virtual void InitializeUI() OVERRIDE {
device_manager_ = CreateDeviceManager();
window_manager_.reset(new TestWindowManager(file_path_));
window_manager_->Initialize();
event_factory_ozone_.reset(new TestEventFactory());
......@@ -83,7 +81,6 @@ class OzonePlatformTest : public OzonePlatform {
}
private:
scoped_ptr<DeviceManager> device_manager_;
scoped_ptr<TestWindowManager> window_manager_;
scoped_ptr<TestEventFactory> event_factory_ozone_;
scoped_ptr<CursorFactoryOzone> cursor_factory_ozone_;
......@@ -98,7 +95,7 @@ class OzonePlatformTest : public OzonePlatform {
OzonePlatform* CreateOzonePlatformTest() {
CommandLine* cmd = CommandLine::ForCurrentProcess();
base::FilePath location = base::FilePath("/dev/null");
base::FilePath location;
if (cmd->HasSwitch(switches::kOzoneDumpFile))
location = cmd->GetSwitchValuePath(switches::kOzoneDumpFile);
return new OzonePlatformTest(location);
......
......@@ -19,19 +19,16 @@ TestWindow::TestWindow(PlatformWindowDelegate* delegate,
const gfx::Rect& bounds)
: delegate_(delegate), manager_(manager), bounds_(bounds) {
widget_ = manager_->AddWindow(this);
ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this);
delegate_->OnAcceleratedWidgetAvailable(widget_);
}
TestWindow::~TestWindow() {
ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this);
manager_->RemoveWindow(widget_, this);
}
base::FilePath TestWindow::path() {
base::FilePath base_path = manager_->base_path();
if (base_path == base::FilePath("/dev/null"))
if (base_path.empty() || base_path == base::FilePath("/dev/null"))
return base_path;
// Disambiguate multiple window output files with the window id.
......@@ -80,14 +77,4 @@ void TestWindow::SetCursor(PlatformCursor cursor) {
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
......@@ -6,7 +6,6 @@
#define UI_OZONE_PLATFORM_TEST_TEST_WINDOW_H_
#include "base/files/file_path.h"
#include "ui/events/platform/platform_event_dispatcher.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/platform_window/platform_window.h"
......@@ -16,7 +15,7 @@ namespace ui {
class PlatformWindowDelegate;
class TestWindowManager;
class TestWindow : public PlatformWindow, public PlatformEventDispatcher {
class TestWindow : public PlatformWindow {
public:
TestWindow(PlatformWindowDelegate* delegate,
TestWindowManager* manager,
......@@ -41,10 +40,6 @@ class TestWindow : public PlatformWindow, public PlatformEventDispatcher {
virtual void SetCursor(PlatformCursor cursor) 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:
PlatformWindowDelegate* delegate_;
TestWindowManager* manager_;
......
......@@ -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";
......
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