Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 } | |
|
abarth
2016/03/09 04:06:36
These are pretty general functions. They're not r
jeffbrown
2016/03/09 19:43:43
Yeah, I could probably put this one into geometry_
| |
| 27 | |
| 28 inline mojo::TransformPtr MakeTransform(float x) { | |
|
abarth
2016/03/09 04:06:36
I don't quite get this one. MakeScaleTransform?
jeffbrown
2016/03/09 19:43:43
Renaming to MakeDummyTransform.
| |
| 29 auto result = mojo::Transform::New(); | |
| 30 result->matrix[0] = x; | |
| 31 return result.Pass(); | |
| 32 } | |
| 33 | |
| 34 inline mojo::gfx::composition::SceneTokenPtr MakeSceneToken(uint32_t value) { | |
| 35 auto result = mojo::gfx::composition::SceneToken::New(); | |
| 36 result->value = value; | |
| 37 return result.Pass(); | |
| 38 } | |
| 39 | |
| 40 inline mojo::ui::ViewTokenPtr MakeViewToken(uint32_t value) { | |
| 41 auto result = mojo::ui::ViewToken::New(); | |
| 42 result->value = value; | |
| 43 return result.Pass(); | |
| 44 } | |
| 45 | |
| 46 inline mojo::gfx::composition::HitTestResultPtr MakeSimpleHitTestResult( | |
| 47 mojo::gfx::composition::SceneTokenPtr scene_token, | |
| 48 mojo::TransformPtr transform) { | |
| 49 auto result = mojo::gfx::composition::HitTestResult::New(); | |
| 50 result->root = mojo::gfx::composition::SceneHit::New(); | |
| 51 result->root->scene_token = scene_token.Pass(); | |
| 52 result->root->hits.push_back(mojo::gfx::composition::Hit::New()); | |
| 53 result->root->hits[0]->set_node(mojo::gfx::composition::NodeHit::New()); | |
| 54 result->root->hits[0]->get_node()->transform = transform.Pass(); | |
| 55 return result.Pass(); | |
| 56 } | |
| 57 | |
| 58 inline mojo::gfx::composition::HitTestResultPtr MakeSimpleHitTestResult( | |
| 59 mojo::gfx::composition::SceneTokenPtr scene_token) { | |
| 60 return MakeSimpleHitTestResult(scene_token.Pass(), MakeTransform(0.f)); | |
| 61 } | |
| 62 | |
| 63 } // namespace test | |
| 64 | |
| 65 #endif // MOJO_UI_ASSOCIATES_TEST_HELPERS_H_ | |
| OLD | NEW |