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

Side by Side Diff: components/mus/ws/test_change_tracker.h

Issue 1406153004: components/mus/public/interfaces View => Window (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Yet another rebase Created 5 years, 2 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/ws/server_view_surface.cc ('k') | components/mus/ws/test_change_tracker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef COMPONENTS_MUS_WS_TEST_CHANGE_TRACKER_H_ 5 #ifndef COMPONENTS_MUS_WS_TEST_CHANGE_TRACKER_H_
6 #define COMPONENTS_MUS_WS_TEST_CHANGE_TRACKER_H_ 6 #define COMPONENTS_MUS_WS_TEST_CHANGE_TRACKER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "components/mus/public/cpp/types.h" 12 #include "components/mus/public/cpp/types.h"
13 #include "components/mus/public/interfaces/view_tree.mojom.h" 13 #include "components/mus/public/interfaces/window_tree.mojom.h"
14 #include "third_party/mojo/src/mojo/public/cpp/bindings/array.h" 14 #include "third_party/mojo/src/mojo/public/cpp/bindings/array.h"
15 #include "ui/mojo/geometry/geometry.mojom.h" 15 #include "ui/mojo/geometry/geometry.mojom.h"
16 16
17 namespace mus { 17 namespace mus {
18 18
19 enum ChangeType { 19 enum ChangeType {
20 CHANGE_TYPE_EMBED, 20 CHANGE_TYPE_EMBED,
21 CHANGE_TYPE_EMBEDDED_APP_DISCONNECTED, 21 CHANGE_TYPE_EMBEDDED_APP_DISCONNECTED,
22 CHANGE_TYPE_UNEMBED, 22 CHANGE_TYPE_UNEMBED,
23 // TODO(sky): nuke NODE. 23 // TODO(sky): nuke NODE.
24 CHANGE_TYPE_NODE_BOUNDS_CHANGED, 24 CHANGE_TYPE_NODE_BOUNDS_CHANGED,
25 CHANGE_TYPE_NODE_VIEWPORT_METRICS_CHANGED, 25 CHANGE_TYPE_NODE_VIEWPORT_METRICS_CHANGED,
26 CHANGE_TYPE_NODE_HIERARCHY_CHANGED, 26 CHANGE_TYPE_NODE_HIERARCHY_CHANGED,
27 CHANGE_TYPE_NODE_REORDERED, 27 CHANGE_TYPE_NODE_REORDERED,
28 CHANGE_TYPE_NODE_VISIBILITY_CHANGED, 28 CHANGE_TYPE_NODE_VISIBILITY_CHANGED,
29 CHANGE_TYPE_NODE_DRAWN_STATE_CHANGED, 29 CHANGE_TYPE_NODE_DRAWN_STATE_CHANGED,
30 CHANGE_TYPE_NODE_DELETED, 30 CHANGE_TYPE_NODE_DELETED,
31 CHANGE_TYPE_INPUT_EVENT, 31 CHANGE_TYPE_INPUT_EVENT,
32 CHANGE_TYPE_PROPERTY_CHANGED, 32 CHANGE_TYPE_PROPERTY_CHANGED,
33 CHANGE_TYPE_DELEGATE_EMBED, 33 CHANGE_TYPE_DELEGATE_EMBED,
34 CHANGE_TYPE_FOCUSED, 34 CHANGE_TYPE_FOCUSED,
35 }; 35 };
36 36
37 // TODO(sky): consider nuking and converting directly to ViewData. 37 // TODO(sky): consider nuking and converting directly to WindowData.
38 struct TestView { 38 struct TestView {
39 TestView(); 39 TestView();
40 ~TestView(); 40 ~TestView();
41 41
42 // Returns a string description of this. 42 // Returns a string description of this.
43 std::string ToString() const; 43 std::string ToString() const;
44 44
45 // Returns a string description that includes visible and drawn. 45 // Returns a string description that includes visible and drawn.
46 std::string ToString2() const; 46 std::string ToString2() const;
47 47
48 Id parent_id; 48 Id parent_id;
49 Id view_id; 49 Id window_id;
50 bool visible; 50 bool visible;
51 bool drawn; 51 bool drawn;
52 std::map<std::string, std::vector<uint8_t>> properties; 52 std::map<std::string, std::vector<uint8_t>> properties;
53 }; 53 };
54 54
55 // Tracks a call to ViewTreeClient. See the individual functions for the fields 55 // Tracks a call to ViewTreeClient. See the individual functions for the fields
56 // that are used. 56 // that are used.
57 struct Change { 57 struct Change {
58 Change(); 58 Change();
59 ~Change(); 59 ~Change();
60 60
61 ChangeType type; 61 ChangeType type;
62 ConnectionSpecificId connection_id; 62 ConnectionSpecificId connection_id;
63 std::vector<TestView> views; 63 std::vector<TestView> views;
64 Id view_id; 64 Id window_id;
65 Id view_id2; 65 Id window_id2;
66 Id view_id3; 66 Id window_id3;
67 mojo::Rect bounds; 67 mojo::Rect bounds;
68 mojo::Rect bounds2; 68 mojo::Rect bounds2;
69 int32_t event_action; 69 int32_t event_action;
70 mojo::String embed_url; 70 mojo::String embed_url;
71 mojo::OrderDirection direction; 71 mojom::OrderDirection direction;
72 bool bool_value; 72 bool bool_value;
73 std::string property_key; 73 std::string property_key;
74 std::string property_value; 74 std::string property_value;
75 }; 75 };
76 76
77 // Converts Changes to string descriptions. 77 // Converts Changes to string descriptions.
78 std::vector<std::string> ChangesToDescription1( 78 std::vector<std::string> ChangesToDescription1(
79 const std::vector<Change>& changes); 79 const std::vector<Change>& changes);
80 80
81 // Convenience for returning the description of the first item in |changes|. 81 // Convenience for returning the description of the first item in |changes|.
82 // Returns an empty string if |changes| has something other than one entry. 82 // Returns an empty string if |changes| has something other than one entry.
83 std::string SingleChangeToDescription(const std::vector<Change>& changes); 83 std::string SingleChangeToDescription(const std::vector<Change>& changes);
84 84
85 // Convenience for returning the description of the first item in |views|. 85 // Convenience for returning the description of the first item in |views|.
86 // Returns an empty string if |views| has something other than one entry. 86 // Returns an empty string if |views| has something other than one entry.
87 std::string SingleViewDescription(const std::vector<TestView>& views); 87 std::string SingleViewDescription(const std::vector<TestView>& views);
88 88
89 // Returns a string description of |changes[0].views|. Returns an empty string 89 // Returns a string description of |changes[0].views|. Returns an empty string
90 // if change.size() != 1. 90 // if change.size() != 1.
91 std::string ChangeViewDescription(const std::vector<Change>& changes); 91 std::string ChangeViewDescription(const std::vector<Change>& changes);
92 92
93 // Converts ViewDatas to TestViews. 93 // Converts WindowDatas to TestViews.
94 void ViewDatasToTestViews(const mojo::Array<mojo::ViewDataPtr>& data, 94 void WindowDatasToTestViews(const mojo::Array<mojom::WindowDataPtr>& data,
95 std::vector<TestView>* test_views); 95 std::vector<TestView>* test_views);
96 96
97 // TestChangeTracker is used to record ViewTreeClient functions. It notifies 97 // TestChangeTracker is used to record ViewTreeClient functions. It notifies
98 // a delegate any time a change is added. 98 // a delegate any time a change is added.
99 class TestChangeTracker { 99 class TestChangeTracker {
100 public: 100 public:
101 // Used to notify the delegate when a change is added. A change corresponds to 101 // Used to notify the delegate when a change is added. A change corresponds to
102 // a single ViewTreeClient function. 102 // a single ViewTreeClient function.
103 class Delegate { 103 class Delegate {
104 public: 104 public:
105 virtual void OnChangeAdded() = 0; 105 virtual void OnChangeAdded() = 0;
106 106
107 protected: 107 protected:
108 virtual ~Delegate() {} 108 virtual ~Delegate() {}
109 }; 109 };
110 110
111 TestChangeTracker(); 111 TestChangeTracker();
112 ~TestChangeTracker(); 112 ~TestChangeTracker();
113 113
114 void set_delegate(Delegate* delegate) { delegate_ = delegate; } 114 void set_delegate(Delegate* delegate) { delegate_ = delegate; }
115 115
116 std::vector<Change>* changes() { return &changes_; } 116 std::vector<Change>* changes() { return &changes_; }
117 117
118 // Each of these functions generate a Change. There is one per 118 // Each of these functions generate a Change. There is one per
119 // ViewTreeClient function. 119 // ViewTreeClient function.
120 void OnEmbed(ConnectionSpecificId connection_id, mojo::ViewDataPtr root); 120 void OnEmbed(ConnectionSpecificId connection_id, mojom::WindowDataPtr root);
121 void OnEmbeddedAppDisconnected(Id view_id); 121 void OnEmbeddedAppDisconnected(Id window_id);
122 void OnUnembed(); 122 void OnUnembed();
123 void OnWindowBoundsChanged(Id view_id, 123 void OnWindowBoundsChanged(Id window_id,
124 mojo::RectPtr old_bounds, 124 mojo::RectPtr old_bounds,
125 mojo::RectPtr new_bounds); 125 mojo::RectPtr new_bounds);
126 void OnWindowViewportMetricsChanged(mojo::ViewportMetricsPtr old_bounds, 126 void OnWindowViewportMetricsChanged(mojom::ViewportMetricsPtr old_bounds,
127 mojo::ViewportMetricsPtr new_bounds); 127 mojom::ViewportMetricsPtr new_bounds);
128 void OnWindowHierarchyChanged(Id view_id, 128 void OnWindowHierarchyChanged(Id window_id,
129 Id new_parent_id, 129 Id new_parent_id,
130 Id old_parent_id, 130 Id old_parent_id,
131 mojo::Array<mojo::ViewDataPtr> views); 131 mojo::Array<mojom::WindowDataPtr> views);
132 void OnWindowReordered(Id view_id, 132 void OnWindowReordered(Id window_id,
133 Id relative_view_id, 133 Id relative_window_id,
134 mojo::OrderDirection direction); 134 mojom::OrderDirection direction);
135 void OnWindowDeleted(Id view_id); 135 void OnWindowDeleted(Id window_id);
136 void OnWindowVisibilityChanged(Id view_id, bool visible); 136 void OnWindowVisibilityChanged(Id window_id, bool visible);
137 void OnWindowDrawnStateChanged(Id view_id, bool drawn); 137 void OnWindowDrawnStateChanged(Id window_id, bool drawn);
138 void OnWindowInputEvent(Id view_id, mojo::EventPtr event); 138 void OnWindowInputEvent(Id window_id, mojo::EventPtr event);
139 void OnWindowSharedPropertyChanged(Id view_id, 139 void OnWindowSharedPropertyChanged(Id window_id,
140 mojo::String name, 140 mojo::String name,
141 mojo::Array<uint8_t> data); 141 mojo::Array<uint8_t> data);
142 void OnWindowFocused(Id view_id); 142 void OnWindowFocused(Id window_id);
143 void DelegateEmbed(const mojo::String& url); 143 void DelegateEmbed(const mojo::String& url);
144 144
145 private: 145 private:
146 void AddChange(const Change& change); 146 void AddChange(const Change& change);
147 147
148 Delegate* delegate_; 148 Delegate* delegate_;
149 std::vector<Change> changes_; 149 std::vector<Change> changes_;
150 150
151 DISALLOW_COPY_AND_ASSIGN(TestChangeTracker); 151 DISALLOW_COPY_AND_ASSIGN(TestChangeTracker);
152 }; 152 };
153 153
154 } // namespace mus 154 } // namespace mus
155 155
156 #endif // COMPONENTS_MUS_WS_TEST_CHANGE_TRACKER_H_ 156 #endif // COMPONENTS_MUS_WS_TEST_CHANGE_TRACKER_H_
OLDNEW
« no previous file with comments | « components/mus/ws/server_view_surface.cc ('k') | components/mus/ws/test_change_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698