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

Side by Side Diff: mojo/ui/associates/test_helpers.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/resolved_hits.cc ('k') | mojo/ui/associates/view_inspector_client.h » ('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_TEST_HELPERS_H_
6 #define MOJO_UI_ASSOCIATES_TEST_HELPERS_H_
7
8 #include <utility>
9
10 #include "base/callback.h"
11 #include "mojo/services/ui/views/interfaces/view_associates.mojom.h"
12
13 namespace test {
14
15 template <typename T>
16 void Capture(const base::Closure& quit, T* out, T value) {
17 *out = std::move(value);
18 quit.Run();
19 }
20
21 inline mojo::PointPtr MakePoint(int32_t x, int32_t y) {
22 auto result = mojo::Point::New();
23 result->x = x;
24 result->y = y;
25 return result.Pass();
26 }
27
28 inline mojo::TransformPtr MakeDummyTransform(float x) {
29 auto result = mojo::Transform::New();
30 result->matrix.resize(16u);
31 result->matrix[0] = x;
32 return result.Pass();
33 }
34
35 inline mojo::gfx::composition::SceneTokenPtr MakeDummySceneToken(
36 uint32_t value) {
37 auto result = mojo::gfx::composition::SceneToken::New();
38 result->value = value;
39 return result.Pass();
40 }
41
42 inline mojo::ui::ViewTokenPtr MakeDummyViewToken(uint32_t value) {
43 auto result = mojo::ui::ViewToken::New();
44 result->value = value;
45 return result.Pass();
46 }
47
48 inline mojo::gfx::composition::HitTestResultPtr MakeSimpleHitTestResult(
49 mojo::gfx::composition::SceneTokenPtr scene_token,
50 mojo::TransformPtr transform) {
51 auto result = mojo::gfx::composition::HitTestResult::New();
52 result->root = mojo::gfx::composition::SceneHit::New();
53 result->root->scene_token = scene_token.Pass();
54 result->root->hits.push_back(mojo::gfx::composition::Hit::New());
55 result->root->hits[0]->set_node(mojo::gfx::composition::NodeHit::New());
56 result->root->hits[0]->get_node()->transform = transform.Pass();
57 return result.Pass();
58 }
59
60 inline mojo::gfx::composition::HitTestResultPtr MakeSimpleHitTestResult(
61 mojo::gfx::composition::SceneTokenPtr scene_token) {
62 return MakeSimpleHitTestResult(scene_token.Pass(), MakeDummyTransform(0.f));
63 }
64
65 } // namespace test
66
67 #endif // MOJO_UI_ASSOCIATES_TEST_HELPERS_H_
OLDNEW
« no previous file with comments | « mojo/ui/associates/resolved_hits.cc ('k') | mojo/ui/associates/view_inspector_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698