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

Side by Side Diff: components/view_manager/test_change_tracker.h

Issue 1314953002: Rename ViewManagerService,ViewManagerClient -> ViewTree,ViewTreeClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 3 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/view_manager/server_view.h ('k') | components/view_manager/view_manager_app.h » ('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_VIEW_MANAGER_TEST_CHANGE_TRACKER_H_ 5 #ifndef COMPONENTS_VIEW_MANAGER_TEST_CHANGE_TRACKER_H_
6 #define COMPONENTS_VIEW_MANAGER_TEST_CHANGE_TRACKER_H_ 6 #define COMPONENTS_VIEW_MANAGER_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/view_manager/public/cpp/types.h" 12 #include "components/view_manager/public/cpp/types.h"
13 #include "components/view_manager/public/interfaces/view_manager.mojom.h" 13 #include "components/view_manager/public/interfaces/view_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 view_manager { 17 namespace view_manager {
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_EMBED_FOR_DESCENDANT, 22 CHANGE_TYPE_EMBED_FOR_DESCENDANT,
23 CHANGE_TYPE_UNEMBED, 23 CHANGE_TYPE_UNEMBED,
(...skipping 22 matching lines...) Expand all
46 // Returns a string description that includes visible and drawn. 46 // Returns a string description that includes visible and drawn.
47 std::string ToString2() const; 47 std::string ToString2() const;
48 48
49 mojo::Id parent_id; 49 mojo::Id parent_id;
50 mojo::Id view_id; 50 mojo::Id view_id;
51 bool visible; 51 bool visible;
52 bool drawn; 52 bool drawn;
53 std::map<std::string, std::vector<uint8_t>> properties; 53 std::map<std::string, std::vector<uint8_t>> properties;
54 }; 54 };
55 55
56 // Tracks a call to ViewManagerClient. See the individual functions for the 56 // Tracks a call to ViewTreeClient. See the individual functions for the fields
57 // fields that are used. 57 // that are used.
58 struct Change { 58 struct Change {
59 Change(); 59 Change();
60 ~Change(); 60 ~Change();
61 61
62 ChangeType type; 62 ChangeType type;
63 mojo::ConnectionSpecificId connection_id; 63 mojo::ConnectionSpecificId connection_id;
64 std::vector<TestView> views; 64 std::vector<TestView> views;
65 mojo::Id view_id; 65 mojo::Id view_id;
66 mojo::Id view_id2; 66 mojo::Id view_id2;
67 mojo::Id view_id3; 67 mojo::Id view_id3;
(...skipping 20 matching lines...) Expand all
88 std::string SingleViewDescription(const std::vector<TestView>& views); 88 std::string SingleViewDescription(const std::vector<TestView>& views);
89 89
90 // Returns a string description of |changes[0].views|. Returns an empty string 90 // Returns a string description of |changes[0].views|. Returns an empty string
91 // if change.size() != 1. 91 // if change.size() != 1.
92 std::string ChangeViewDescription(const std::vector<Change>& changes); 92 std::string ChangeViewDescription(const std::vector<Change>& changes);
93 93
94 // Converts ViewDatas to TestViews. 94 // Converts ViewDatas to TestViews.
95 void ViewDatasToTestViews(const mojo::Array<mojo::ViewDataPtr>& data, 95 void ViewDatasToTestViews(const mojo::Array<mojo::ViewDataPtr>& data,
96 std::vector<TestView>* test_views); 96 std::vector<TestView>* test_views);
97 97
98 // TestChangeTracker is used to record ViewManagerClient functions. It notifies 98 // TestChangeTracker is used to record ViewTreeClient functions. It notifies
99 // a delegate any time a change is added. 99 // a delegate any time a change is added.
100 class TestChangeTracker { 100 class TestChangeTracker {
101 public: 101 public:
102 // Used to notify the delegate when a change is added. A change corresponds to 102 // Used to notify the delegate when a change is added. A change corresponds to
103 // a single ViewManagerClient function. 103 // a single ViewTreeClient function.
104 class Delegate { 104 class Delegate {
105 public: 105 public:
106 virtual void OnChangeAdded() = 0; 106 virtual void OnChangeAdded() = 0;
107 107
108 protected: 108 protected:
109 virtual ~Delegate() {} 109 virtual ~Delegate() {}
110 }; 110 };
111 111
112 TestChangeTracker(); 112 TestChangeTracker();
113 ~TestChangeTracker(); 113 ~TestChangeTracker();
114 114
115 void set_delegate(Delegate* delegate) { 115 void set_delegate(Delegate* delegate) {
116 delegate_ = delegate; 116 delegate_ = delegate;
117 } 117 }
118 118
119 std::vector<Change>* changes() { return &changes_; } 119 std::vector<Change>* changes() { return &changes_; }
120 120
121 // Each of these functions generate a Change. There is one per 121 // Each of these functions generate a Change. There is one per
122 // ViewManagerClient function. 122 // ViewTreeClient function.
123 void OnEmbed(mojo::ConnectionSpecificId connection_id, 123 void OnEmbed(mojo::ConnectionSpecificId connection_id,
124 mojo::ViewDataPtr root); 124 mojo::ViewDataPtr root);
125 void OnEmbedForDescendant(mojo::Id view_id); 125 void OnEmbedForDescendant(mojo::Id view_id);
126 void OnEmbeddedAppDisconnected(mojo::Id view_id); 126 void OnEmbeddedAppDisconnected(mojo::Id view_id);
127 void OnUnembed(); 127 void OnUnembed();
128 void OnViewBoundsChanged(mojo::Id view_id, 128 void OnViewBoundsChanged(mojo::Id view_id,
129 mojo::RectPtr old_bounds, 129 mojo::RectPtr old_bounds,
130 mojo::RectPtr new_bounds); 130 mojo::RectPtr new_bounds);
131 void OnViewViewportMetricsChanged(mojo::ViewportMetricsPtr old_bounds, 131 void OnViewViewportMetricsChanged(mojo::ViewportMetricsPtr old_bounds,
132 mojo::ViewportMetricsPtr new_bounds); 132 mojo::ViewportMetricsPtr new_bounds);
(...skipping 19 matching lines...) Expand all
152 152
153 Delegate* delegate_; 153 Delegate* delegate_;
154 std::vector<Change> changes_; 154 std::vector<Change> changes_;
155 155
156 DISALLOW_COPY_AND_ASSIGN(TestChangeTracker); 156 DISALLOW_COPY_AND_ASSIGN(TestChangeTracker);
157 }; 157 };
158 158
159 } // namespace view_manager 159 } // namespace view_manager
160 160
161 #endif // COMPONENTS_VIEW_MANAGER_TEST_CHANGE_TRACKER_H_ 161 #endif // COMPONENTS_VIEW_MANAGER_TEST_CHANGE_TRACKER_H_
OLDNEW
« no previous file with comments | « components/view_manager/server_view.h ('k') | components/view_manager/view_manager_app.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698