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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: mojo/ui/associates/test_helpers.h
diff --git a/mojo/ui/associates/test_helpers.h b/mojo/ui/associates/test_helpers.h
new file mode 100644
index 0000000000000000000000000000000000000000..b5e29a403ea35c4429c887e3eb6f2f45cedc95f2
--- /dev/null
+++ b/mojo/ui/associates/test_helpers.h
@@ -0,0 +1,65 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOJO_UI_ASSOCIATES_TEST_HELPERS_H_
+#define MOJO_UI_ASSOCIATES_TEST_HELPERS_H_
+
+#include <utility>
+
+#include "base/callback.h"
+#include "mojo/services/ui/views/interfaces/view_associates.mojom.h"
+
+namespace test {
+
+template <typename T>
+void Capture(const base::Closure& quit, T* out, T value) {
+ *out = std::move(value);
+ quit.Run();
+}
+
+inline mojo::PointPtr MakePoint(int32_t x, int32_t y) {
+ auto result = mojo::Point::New();
+ result->x = x;
+ result->y = y;
+ return result.Pass();
+}
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_
+
+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.
+ auto result = mojo::Transform::New();
+ result->matrix[0] = x;
+ return result.Pass();
+}
+
+inline mojo::gfx::composition::SceneTokenPtr MakeSceneToken(uint32_t value) {
+ auto result = mojo::gfx::composition::SceneToken::New();
+ result->value = value;
+ return result.Pass();
+}
+
+inline mojo::ui::ViewTokenPtr MakeViewToken(uint32_t value) {
+ auto result = mojo::ui::ViewToken::New();
+ result->value = value;
+ return result.Pass();
+}
+
+inline mojo::gfx::composition::HitTestResultPtr MakeSimpleHitTestResult(
+ mojo::gfx::composition::SceneTokenPtr scene_token,
+ mojo::TransformPtr transform) {
+ auto result = mojo::gfx::composition::HitTestResult::New();
+ result->root = mojo::gfx::composition::SceneHit::New();
+ result->root->scene_token = scene_token.Pass();
+ result->root->hits.push_back(mojo::gfx::composition::Hit::New());
+ result->root->hits[0]->set_node(mojo::gfx::composition::NodeHit::New());
+ result->root->hits[0]->get_node()->transform = transform.Pass();
+ return result.Pass();
+}
+
+inline mojo::gfx::composition::HitTestResultPtr MakeSimpleHitTestResult(
+ mojo::gfx::composition::SceneTokenPtr scene_token) {
+ return MakeSimpleHitTestResult(scene_token.Pass(), MakeTransform(0.f));
+}
+
+} // namespace test
+
+#endif // MOJO_UI_ASSOCIATES_TEST_HELPERS_H_

Powered by Google App Engine
This is Rietveld 408576698