| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/test_window.h" | 5 #include "ui/ozone/platform/test/test_window.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "ui/events/platform/platform_event_source.h" | 11 #include "ui/events/platform/platform_event_source.h" |
| 12 #include "ui/ozone/platform/test/test_window_manager.h" | 12 #include "ui/ozone/platform/test/test_window_manager.h" |
| 13 #include "ui/platform_window/platform_window_delegate.h" | 13 #include "ui/platform_window/platform_window_delegate.h" |
| 14 | 14 |
| 15 namespace ui { | 15 namespace ui { |
| 16 | 16 |
| 17 TestWindow::TestWindow(PlatformWindowDelegate* delegate, | 17 TestWindow::TestWindow(PlatformWindowDelegate* delegate, |
| 18 TestWindowManager* manager, | 18 TestWindowManager* manager, |
| 19 const gfx::Rect& bounds) | 19 const gfx::Rect& bounds) |
| 20 : delegate_(delegate), manager_(manager), bounds_(bounds) { | 20 : delegate_(delegate), manager_(manager), bounds_(bounds) { |
| 21 widget_ = manager_->AddWindow(this); | 21 widget_ = manager_->AddWindow(this); |
| 22 ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); | |
| 23 delegate_->OnAcceleratedWidgetAvailable(widget_); | 22 delegate_->OnAcceleratedWidgetAvailable(widget_); |
| 24 } | 23 } |
| 25 | 24 |
| 26 TestWindow::~TestWindow() { | 25 TestWindow::~TestWindow() { |
| 27 ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this); | |
| 28 manager_->RemoveWindow(widget_, this); | 26 manager_->RemoveWindow(widget_, this); |
| 29 } | 27 } |
| 30 | 28 |
| 31 base::FilePath TestWindow::path() { | 29 base::FilePath TestWindow::path() { |
| 32 base::FilePath base_path = manager_->base_path(); | 30 base::FilePath base_path = manager_->base_path(); |
| 33 | 31 if (base_path.empty() || base_path == base::FilePath("/dev/null")) |
| 34 if (base_path == base::FilePath("/dev/null")) | |
| 35 return base_path; | 32 return base_path; |
| 36 | 33 |
| 37 // Disambiguate multiple window output files with the window id. | 34 // Disambiguate multiple window output files with the window id. |
| 38 return base_path.Append(base::IntToString(widget_)); | 35 return base_path.Append(base::IntToString(widget_)); |
| 39 } | 36 } |
| 40 | 37 |
| 41 gfx::Rect TestWindow::GetBounds() { | 38 gfx::Rect TestWindow::GetBounds() { |
| 42 return bounds_; | 39 return bounds_; |
| 43 } | 40 } |
| 44 | 41 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 73 | 70 |
| 74 void TestWindow::Restore() { | 71 void TestWindow::Restore() { |
| 75 } | 72 } |
| 76 | 73 |
| 77 void TestWindow::SetCursor(PlatformCursor cursor) { | 74 void TestWindow::SetCursor(PlatformCursor cursor) { |
| 78 } | 75 } |
| 79 | 76 |
| 80 void TestWindow::MoveCursorTo(const gfx::Point& location) { | 77 void TestWindow::MoveCursorTo(const gfx::Point& location) { |
| 81 } | 78 } |
| 82 | 79 |
| 83 bool TestWindow::CanDispatchEvent(const ui::PlatformEvent& ne) { | |
| 84 return true; | |
| 85 } | |
| 86 | |
| 87 uint32_t TestWindow::DispatchEvent(const ui::PlatformEvent& ne) { | |
| 88 ui::Event* event = static_cast<ui::Event*>(ne); | |
| 89 delegate_->DispatchEvent(event); | |
| 90 return ui::POST_DISPATCH_STOP_PROPAGATION; | |
| 91 } | |
| 92 | |
| 93 } // namespace ui | 80 } // namespace ui |
| OLD | NEW |