| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/aura/test/mus/test_window_tree.h" | 5 #include "ui/aura/test/mus/test_window_tree.h" |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 8 |
| 9 namespace aura { | 9 namespace aura { |
| 10 | 10 |
| 11 TestWindowTree::TestWindowTree() {} | 11 TestWindowTree::TestWindowTree() {} |
| 12 | 12 |
| 13 TestWindowTree::~TestWindowTree() {} | 13 TestWindowTree::~TestWindowTree() {} |
| 14 | 14 |
| 15 bool TestWindowTree::WasEventAcked(uint32_t event_id) const { | 15 bool TestWindowTree::WasEventAcked(uint32_t event_id) const { |
| 16 return acked_events_.count(event_id); | 16 return acked_events_.count(event_id); |
| 17 } | 17 } |
| 18 | 18 |
| 19 mojo::Array<uint8_t> TestWindowTree::GetLastPropertyValue() { | 19 base::Optional<std::vector<uint8_t>> TestWindowTree::GetLastPropertyValue() { |
| 20 return std::move(last_property_value_); | 20 return std::move(last_property_value_); |
| 21 } | 21 } |
| 22 | 22 |
| 23 mojo::Map<mojo::String, mojo::Array<uint8_t>> | 23 base::Optional<std::unordered_map<std::string, std::vector<uint8_t>>> |
| 24 TestWindowTree::GetLastNewWindowProperties() { | 24 TestWindowTree::GetLastNewWindowProperties() { |
| 25 return std::move(last_new_window_properties_); | 25 return std::move(last_new_window_properties_); |
| 26 } | 26 } |
| 27 | 27 |
| 28 void TestWindowTree::AckAllChanges() { | 28 void TestWindowTree::AckAllChanges() { |
| 29 while (!changes_.empty()) { | 29 while (!changes_.empty()) { |
| 30 client_->OnChangeCompleted(changes_[0].id, true); | 30 client_->OnChangeCompleted(changes_[0].id, true); |
| 31 changes_.erase(changes_.begin()); | 31 changes_.erase(changes_.begin()); |
| 32 } | 32 } |
| 33 } | 33 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 } | 95 } |
| 96 | 96 |
| 97 void TestWindowTree::OnChangeReceived(uint32_t change_id, | 97 void TestWindowTree::OnChangeReceived(uint32_t change_id, |
| 98 WindowTreeChangeType type) { | 98 WindowTreeChangeType type) { |
| 99 changes_.push_back({type, change_id}); | 99 changes_.push_back({type, change_id}); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void TestWindowTree::NewWindow( | 102 void TestWindowTree::NewWindow( |
| 103 uint32_t change_id, | 103 uint32_t change_id, |
| 104 uint32_t window_id, | 104 uint32_t window_id, |
| 105 mojo::Map<mojo::String, mojo::Array<uint8_t>> properties) { | 105 const base::Optional<std::unordered_map<std::string, std::vector<uint8_t>>>& |
| 106 last_new_window_properties_ = std::move(properties); | 106 properties) { |
| 107 last_new_window_properties_ = properties; |
| 107 OnChangeReceived(change_id, WindowTreeChangeType::NEW_WINDOW); | 108 OnChangeReceived(change_id, WindowTreeChangeType::NEW_WINDOW); |
| 108 } | 109 } |
| 109 | 110 |
| 110 void TestWindowTree::NewTopLevelWindow( | 111 void TestWindowTree::NewTopLevelWindow( |
| 111 uint32_t change_id, | 112 uint32_t change_id, |
| 112 uint32_t window_id, | 113 uint32_t window_id, |
| 113 mojo::Map<mojo::String, mojo::Array<uint8_t>> properties) { | 114 const std::unordered_map<std::string, std::vector<uint8_t>>& properties) { |
| 114 last_new_window_properties_ = std::move(properties); | 115 last_new_window_properties_.emplace(properties); |
| 115 window_id_ = window_id; | 116 window_id_ = window_id; |
| 116 OnChangeReceived(change_id, WindowTreeChangeType::NEW_TOP_LEVEL); | 117 OnChangeReceived(change_id, WindowTreeChangeType::NEW_TOP_LEVEL); |
| 117 } | 118 } |
| 118 | 119 |
| 119 void TestWindowTree::DeleteWindow(uint32_t change_id, uint32_t window_id) { | 120 void TestWindowTree::DeleteWindow(uint32_t change_id, uint32_t window_id) { |
| 120 OnChangeReceived(change_id); | 121 OnChangeReceived(change_id); |
| 121 } | 122 } |
| 122 | 123 |
| 123 void TestWindowTree::SetWindowBounds(uint32_t change_id, | 124 void TestWindowTree::SetWindowBounds(uint32_t change_id, |
| 124 uint32_t window_id, | 125 uint32_t window_id, |
| 125 const gfx::Rect& bounds) { | 126 const gfx::Rect& bounds) { |
| 126 OnChangeReceived(change_id, WindowTreeChangeType::BOUNDS); | 127 OnChangeReceived(change_id, WindowTreeChangeType::BOUNDS); |
| 127 } | 128 } |
| 128 | 129 |
| 129 void TestWindowTree::SetClientArea( | 130 void TestWindowTree::SetClientArea( |
| 130 uint32_t window_id, | 131 uint32_t window_id, |
| 131 const gfx::Insets& insets, | 132 const gfx::Insets& insets, |
| 132 mojo::Array<gfx::Rect> additional_client_areas) {} | 133 const base::Optional<std::vector<gfx::Rect>>& additional_client_areas) {} |
| 133 | 134 |
| 134 void TestWindowTree::SetHitTestMask(uint32_t window_id, | 135 void TestWindowTree::SetHitTestMask(uint32_t window_id, |
| 135 const base::Optional<gfx::Rect>& mask) {} | 136 const base::Optional<gfx::Rect>& mask) {} |
| 136 | 137 |
| 137 void TestWindowTree::SetCanAcceptDrops(uint32_t window_id, bool accepts_drops) { | 138 void TestWindowTree::SetCanAcceptDrops(uint32_t window_id, bool accepts_drops) { |
| 138 } | 139 } |
| 139 | 140 |
| 140 void TestWindowTree::SetWindowVisibility(uint32_t change_id, | 141 void TestWindowTree::SetWindowVisibility(uint32_t change_id, |
| 141 uint32_t window_id, | 142 uint32_t window_id, |
| 142 bool visible) { | 143 bool visible) { |
| 143 OnChangeReceived(change_id, WindowTreeChangeType::VISIBLE); | 144 OnChangeReceived(change_id, WindowTreeChangeType::VISIBLE); |
| 144 } | 145 } |
| 145 | 146 |
| 146 void TestWindowTree::SetWindowProperty(uint32_t change_id, | 147 void TestWindowTree::SetWindowProperty( |
| 147 uint32_t window_id, | 148 uint32_t change_id, |
| 148 const mojo::String& name, | 149 uint32_t window_id, |
| 149 mojo::Array<uint8_t> value) { | 150 const std::string& name, |
| 150 last_property_value_ = std::move(value); | 151 const base::Optional<std::vector<uint8_t>>& value) { |
| 152 last_property_value_ = value; |
| 151 OnChangeReceived(change_id, WindowTreeChangeType::PROPERTY); | 153 OnChangeReceived(change_id, WindowTreeChangeType::PROPERTY); |
| 152 } | 154 } |
| 153 | 155 |
| 154 void TestWindowTree::SetWindowOpacity(uint32_t change_id, | 156 void TestWindowTree::SetWindowOpacity(uint32_t change_id, |
| 155 uint32_t window_id, | 157 uint32_t window_id, |
| 156 float opacity) { | 158 float opacity) { |
| 157 OnChangeReceived(change_id); | 159 OnChangeReceived(change_id); |
| 158 } | 160 } |
| 159 | 161 |
| 160 void TestWindowTree::AttachCompositorFrameSink( | 162 void TestWindowTree::AttachCompositorFrameSink( |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 } | 256 } |
| 255 | 257 |
| 256 void TestWindowTree::GetCursorLocationMemory( | 258 void TestWindowTree::GetCursorLocationMemory( |
| 257 const GetCursorLocationMemoryCallback& callback) { | 259 const GetCursorLocationMemoryCallback& callback) { |
| 258 callback.Run(mojo::ScopedSharedBufferHandle()); | 260 callback.Run(mojo::ScopedSharedBufferHandle()); |
| 259 } | 261 } |
| 260 | 262 |
| 261 void TestWindowTree::PerformDragDrop( | 263 void TestWindowTree::PerformDragDrop( |
| 262 uint32_t change_id, | 264 uint32_t change_id, |
| 263 uint32_t source_window_id, | 265 uint32_t source_window_id, |
| 264 mojo::Map<mojo::String, mojo::Array<uint8_t>> drag_data, | 266 const std::unordered_map<std::string, std::vector<uint8_t>>& drag_data, |
| 265 uint32_t drag_operation) { | 267 uint32_t drag_operation) { |
| 266 OnChangeReceived(change_id); | 268 OnChangeReceived(change_id); |
| 267 } | 269 } |
| 268 | 270 |
| 269 void TestWindowTree::CancelDragDrop(uint32_t window_id) {} | 271 void TestWindowTree::CancelDragDrop(uint32_t window_id) {} |
| 270 | 272 |
| 271 void TestWindowTree::PerformWindowMove(uint32_t change_id, | 273 void TestWindowTree::PerformWindowMove(uint32_t change_id, |
| 272 uint32_t window_id, | 274 uint32_t window_id, |
| 273 ui::mojom::MoveLoopSource source, | 275 ui::mojom::MoveLoopSource source, |
| 274 const gfx::Point& cursor_location) { | 276 const gfx::Point& cursor_location) { |
| 275 OnChangeReceived(change_id); | 277 OnChangeReceived(change_id); |
| 276 } | 278 } |
| 277 | 279 |
| 278 void TestWindowTree::CancelWindowMove(uint32_t window_id) {} | 280 void TestWindowTree::CancelWindowMove(uint32_t window_id) {} |
| 279 | 281 |
| 280 } // namespace aura | 282 } // namespace aura |
| OLD | NEW |