| 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 "services/ui/public/cpp/window_tree_client.h" | 5 #include "services/ui/public/cpp/window_tree_client.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 namespace { | 33 namespace { |
| 34 | 34 |
| 35 void DoNothingWithEventResult(mojom::EventResult result) {} | 35 void DoNothingWithEventResult(mojom::EventResult result) {} |
| 36 | 36 |
| 37 Id server_id(ui::Window* window) { | 37 Id server_id(ui::Window* window) { |
| 38 return WindowPrivate(window).server_id(); | 38 return WindowPrivate(window).server_id(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 } // namespace | 41 } // namespace |
| 42 | 42 |
| 43 mojo::Array<uint8_t> Int32ToPropertyTransportValue(int32_t value) { | 43 std::vector<uint8_t> Int32ToPropertyTransportValue(int32_t value) { |
| 44 const std::vector<uint8_t> bytes = | 44 return mojo::ConvertTo<std::vector<uint8_t>>(value); |
| 45 mojo::ConvertTo<std::vector<uint8_t>>(value); | |
| 46 mojo::Array<uint8_t> transport_value; | |
| 47 transport_value.resize(bytes.size()); | |
| 48 memcpy(&transport_value.front(), &(bytes.front()), bytes.size()); | |
| 49 return transport_value; | |
| 50 } | 45 } |
| 51 | 46 |
| 52 class TestWindowTreeClientDelegate : public WindowTreeClientDelegate { | 47 class TestWindowTreeClientDelegate : public WindowTreeClientDelegate { |
| 53 public: | 48 public: |
| 54 TestWindowTreeClientDelegate() {} | 49 TestWindowTreeClientDelegate() {} |
| 55 ~TestWindowTreeClientDelegate() override {} | 50 ~TestWindowTreeClientDelegate() override {} |
| 56 | 51 |
| 57 ui::PointerEvent* last_event_observed() { return last_event_observed_.get(); } | 52 ui::PointerEvent* last_event_observed() { return last_event_observed_.get(); } |
| 58 | 53 |
| 59 void Reset() { last_event_observed_.reset(); } | 54 void Reset() { last_event_observed_.reset(); } |
| (...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 uint32_t property_in_flight_change_id; | 767 uint32_t property_in_flight_change_id; |
| 773 ASSERT_TRUE( | 768 ASSERT_TRUE( |
| 774 setup.window_tree()->GetAndClearChangeId(&property_in_flight_change_id)); | 769 setup.window_tree()->GetAndClearChangeId(&property_in_flight_change_id)); |
| 775 EXPECT_NE(bounds_in_flight_change_id, property_in_flight_change_id); | 770 EXPECT_NE(bounds_in_flight_change_id, property_in_flight_change_id); |
| 776 | 771 |
| 777 // Ack the new window top level window. Vis and bounds shouldn't change. | 772 // Ack the new window top level window. Vis and bounds shouldn't change. |
| 778 mojom::WindowDataPtr data = mojom::WindowData::New(); | 773 mojom::WindowDataPtr data = mojom::WindowData::New(); |
| 779 data->window_id = server_id(root2); | 774 data->window_id = server_id(root2); |
| 780 data->bounds.SetRect(1, 2, 3, 4); | 775 data->bounds.SetRect(1, 2, 3, 4); |
| 781 data->visible = true; | 776 data->visible = true; |
| 782 data->properties["xx"] = mojo::Array<uint8_t>::From(std::string("server_xx")); | 777 data->properties["xx"] = |
| 783 data->properties["yy"] = mojo::Array<uint8_t>::From(std::string("server_yy")); | 778 mojo::Array<uint8_t>::From(std::string("server_xx")).PassStorage(); |
| 779 data->properties["yy"] = |
| 780 mojo::Array<uint8_t>::From(std::string("server_yy")).PassStorage(); |
| 784 const int64_t display_id = 1; | 781 const int64_t display_id = 1; |
| 785 setup.window_tree_client()->OnTopLevelCreated( | 782 setup.window_tree_client()->OnTopLevelCreated( |
| 786 new_window_in_flight_change_id, std::move(data), display_id, true); | 783 new_window_in_flight_change_id, std::move(data), display_id, true); |
| 787 | 784 |
| 788 // The only value that should take effect is the property for 'yy' as it was | 785 // The only value that should take effect is the property for 'yy' as it was |
| 789 // not in flight. | 786 // not in flight. |
| 790 EXPECT_TRUE(WindowPrivate(root2).parent_drawn()); | 787 EXPECT_TRUE(WindowPrivate(root2).parent_drawn()); |
| 791 EXPECT_FALSE(root2->visible()); | 788 EXPECT_FALSE(root2->visible()); |
| 792 EXPECT_EQ(1, root2->display_id()); | 789 EXPECT_EQ(1, root2->display_id()); |
| 793 EXPECT_EQ(gfx::Rect(5, 6, 7, 8), root2->bounds()); | 790 EXPECT_EQ(gfx::Rect(5, 6, 7, 8), root2->bounds()); |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1083 | 1080 |
| 1084 // Changes originating from server should notify observers too. | 1081 // Changes originating from server should notify observers too. |
| 1085 WindowTreeClientPrivate(setup.client()).CallOnCaptureChanged(child2, nullptr); | 1082 WindowTreeClientPrivate(setup.client()).CallOnCaptureChanged(child2, nullptr); |
| 1086 EXPECT_EQ(1, capture_recorder.capture_changed_count()); | 1083 EXPECT_EQ(1, capture_recorder.capture_changed_count()); |
| 1087 EXPECT_EQ(child2_id, capture_recorder.last_gained_capture_window_id()); | 1084 EXPECT_EQ(child2_id, capture_recorder.last_gained_capture_window_id()); |
| 1088 EXPECT_EQ(0, capture_recorder.last_lost_capture_window_id()); | 1085 EXPECT_EQ(0, capture_recorder.last_lost_capture_window_id()); |
| 1089 capture_recorder.reset_capture_captured_count(); | 1086 capture_recorder.reset_capture_captured_count(); |
| 1090 } | 1087 } |
| 1091 | 1088 |
| 1092 } // namespace ui | 1089 } // namespace ui |
| OLD | NEW |