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

Side by Side Diff: mojo/ui/associates/mock_view_inspector.h

Issue 1778593003: Mozart: Add helpers for building view associates. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-6
Patch Set: Created 4 years, 9 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 | « mojo/ui/associates/mock_hit_tester.cc ('k') | mojo/ui/associates/mock_view_inspector.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef MOJO_UI_ASSOCIATES_MOCK_VIEW_INSPECTOR_H_
6 #define MOJO_UI_ASSOCIATES_MOCK_VIEW_INSPECTOR_H_
7
8 #include <unordered_map>
9
10 #include "base/macros.h"
11 #include "mojo/common/binding_set.h"
12 #include "mojo/services/ui/views/interfaces/view_associates.mojom.h"
13
14 namespace mojo {
15 namespace ui {
16
17 class MockViewInspector : public ViewInspector {
18 public:
19 MockViewInspector();
20 ~MockViewInspector() override;
21
22 // Sets the hit tester to use for a particular view tree.
23 // Setting to null removes the hit tester.
24 // Does not take ownership; the hit tester must outlive this object.
25 void SetHitTester(uint32_t view_tree_token_value,
26 mojo::gfx::composition::HitTester* hit_tester);
27
28 // Closes all hit tester bindings without invoking the changed callbacks.
29 void CloseHitTesterBindings();
30
31 // Adds a mapping from scene token to view token.
32 // Setting to null removes the scene mapping.
33 void SetSceneMapping(uint32_t scene_token_value,
34 mojo::ui::ViewTokenPtr view_token);
35
36 // Returns how often |GetHitTester| was called.
37 uint32_t hit_tester_lookups() const { return hit_tester_lookups_; }
38
39 // Returns how often |ResolveScenes| was called.
40 uint32_t scene_lookups() const { return scene_lookups_; }
41
42 // |ViewInspector|
43 void GetHitTester(mojo::ui::ViewTreeTokenPtr view_tree_token,
44 mojo::InterfaceRequest<mojo::gfx::composition::HitTester>
45 hit_tester_request,
46 const GetHitTesterCallback& callback) override;
47 void ResolveScenes(
48 mojo::Array<mojo::gfx::composition::SceneTokenPtr> scene_tokens,
49 const ResolveScenesCallback& callback) override;
50
51 private:
52 std::unordered_map<uint32_t, mojo::gfx::composition::HitTester*> hit_testers_;
53 mojo::BindingSet<mojo::gfx::composition::HitTester> hit_tester_bindings_;
54 std::unordered_multimap<uint32_t, GetHitTesterCallback> hit_tester_callbacks_;
55
56 std::unordered_map<uint32_t, mojo::ui::ViewTokenPtr> scene_mappings_;
57
58 uint32_t hit_tester_lookups_ = 0u;
59 uint32_t scene_lookups_ = 0u;
60
61 DISALLOW_COPY_AND_ASSIGN(MockViewInspector);
62 };
63
64 } // namespace ui
65 } // namespace mojo
66
67 #endif // MOJO_UI_ASSOCIATES_MOCK_VIEW_INSPECTOR_H_
OLDNEW
« no previous file with comments | « mojo/ui/associates/mock_hit_tester.cc ('k') | mojo/ui/associates/mock_view_inspector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698