Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: components/mus/public/cpp/tests/window_tree_client_impl_unittest.cc

Issue 1983243002: Creates mus test helper class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: override Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/mus/public/cpp/tests/window_tree_client_impl_private.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "components/mus/public/cpp/lib/window_tree_client_impl.h" 5 #include "components/mus/public/cpp/lib/window_tree_client_impl.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"
11 #include "components/mus/common/util.h" 11 #include "components/mus/common/util.h"
12 #include "components/mus/public/cpp/input_event_handler.h" 12 #include "components/mus/public/cpp/input_event_handler.h"
13 #include "components/mus/public/cpp/lib/window_private.h" 13 #include "components/mus/public/cpp/lib/window_private.h"
14 #include "components/mus/public/cpp/property_type_converters.h" 14 #include "components/mus/public/cpp/property_type_converters.h"
15 #include "components/mus/public/cpp/tests/test_window.h" 15 #include "components/mus/public/cpp/tests/test_window.h"
16 #include "components/mus/public/cpp/tests/test_window_tree.h" 16 #include "components/mus/public/cpp/tests/test_window_tree.h"
17 #include "components/mus/public/cpp/tests/window_tree_client_impl_private.h"
17 #include "components/mus/public/cpp/window.h" 18 #include "components/mus/public/cpp/window.h"
18 #include "components/mus/public/cpp/window_observer.h" 19 #include "components/mus/public/cpp/window_observer.h"
19 #include "components/mus/public/cpp/window_property.h" 20 #include "components/mus/public/cpp/window_property.h"
20 #include "components/mus/public/cpp/window_tracker.h" 21 #include "components/mus/public/cpp/window_tracker.h"
21 #include "components/mus/public/cpp/window_tree_delegate.h" 22 #include "components/mus/public/cpp/window_tree_delegate.h"
22 #include "mojo/common/common_type_converters.h" 23 #include "mojo/common/common_type_converters.h"
23 #include "mojo/converters/geometry/geometry_type_converters.h" 24 #include "mojo/converters/geometry/geometry_type_converters.h"
24 #include "mojo/converters/input_events/input_events_type_converters.h" 25 #include "mojo/converters/input_events/input_events_type_converters.h"
25 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
26 #include "ui/events/event.h" 27 #include "ui/events/event.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 void OnEventObserved(const ui::Event& event, Window* target) override { 64 void OnEventObserved(const ui::Event& event, Window* target) override {
64 last_event_observed_ = ui::Event::Clone(event); 65 last_event_observed_ = ui::Event::Clone(event);
65 } 66 }
66 67
67 private: 68 private:
68 std::unique_ptr<ui::Event> last_event_observed_; 69 std::unique_ptr<ui::Event> last_event_observed_;
69 70
70 DISALLOW_COPY_AND_ASSIGN(TestWindowTreeDelegate); 71 DISALLOW_COPY_AND_ASSIGN(TestWindowTreeDelegate);
71 }; 72 };
72 73
73 class WindowTreeClientImplPrivate {
74 public:
75 WindowTreeClientImplPrivate(WindowTreeClientImpl* tree_client_impl)
76 : tree_client_impl_(tree_client_impl) {}
77 ~WindowTreeClientImplPrivate() {}
78
79 void Init(mojom::WindowTree* window_tree) {
80 mojom::WindowDataPtr root_data(mojom::WindowData::New());
81 root_data->parent_id = 0;
82 root_data->window_id = 1;
83 root_data->bounds = mojo::Rect::From(gfx::Rect());
84 root_data->properties.SetToEmpty();
85 root_data->visible = true;
86 root_data->viewport_metrics = mojom::ViewportMetrics::New();
87 root_data->viewport_metrics->size_in_pixels =
88 mojo::Size::From(gfx::Size(1000, 1000));
89 root_data->viewport_metrics->device_pixel_ratio = 1;
90 tree_client_impl_->OnEmbedImpl(window_tree, 1, std::move(root_data), 0,
91 true);
92 }
93
94 uint32_t event_observer_id() { return tree_client_impl_->event_observer_id_; }
95
96 private:
97 WindowTreeClientImpl* tree_client_impl_;
98
99 DISALLOW_COPY_AND_ASSIGN(WindowTreeClientImplPrivate);
100 };
101
102 class WindowTreeSetup { 74 class WindowTreeSetup {
103 public: 75 public:
104 WindowTreeSetup() : tree_client_(&window_tree_delegate_, nullptr, nullptr) { 76 WindowTreeSetup() : tree_client_(&window_tree_delegate_, nullptr, nullptr) {
105 WindowTreeClientImplPrivate(&tree_client_).Init(&window_tree_); 77 WindowTreeClientImplPrivate(&tree_client_).OnEmbed(&window_tree_);
106 window_tree_.GetAndClearChangeId(nullptr); 78 window_tree_.GetAndClearChangeId(nullptr);
107 } 79 }
108 80
109 WindowTreeConnection* window_tree_connection() { 81 WindowTreeConnection* window_tree_connection() {
110 return static_cast<WindowTreeConnection*>(&tree_client_); 82 return static_cast<WindowTreeConnection*>(&tree_client_);
111 } 83 }
112 84
113 mojom::WindowTreeClient* window_tree_client() { 85 mojom::WindowTreeClient* window_tree_client() {
114 return static_cast<mojom::WindowTreeClient*>(&tree_client_); 86 return static_cast<mojom::WindowTreeClient*>(&tree_client_);
115 } 87 }
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 1022
1051 setup.window_tree_client()->OnChangeCompleted(change_id2, false); 1023 setup.window_tree_client()->OnChangeCompleted(change_id2, false);
1052 EXPECT_FALSE(child->HasCapture()); 1024 EXPECT_FALSE(child->HasCapture());
1053 EXPECT_TRUE(root->HasCapture()); 1025 EXPECT_TRUE(root->HasCapture());
1054 1026
1055 setup.window_tree_client()->OnLostCapture(server_id(root)); 1027 setup.window_tree_client()->OnLostCapture(server_id(root));
1056 EXPECT_FALSE(root->HasCapture()); 1028 EXPECT_FALSE(root->HasCapture());
1057 } 1029 }
1058 1030
1059 } // namespace mus 1031 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/public/cpp/tests/window_tree_client_impl_private.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698