| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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 #include "chrome/browser/android/vr_shell/ui_scene.h" | 5 #include "chrome/browser/android/vr_shell/ui_scene.h" |
| 6 | 6 |
| 7 #define _USE_MATH_DEFINES // For M_PI in MSVC. | 7 #define _USE_MATH_DEFINES // For M_PI in MSVC. |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 element->size = {1, 1, 1}; | 119 element->size = {1, 1, 1}; |
| 120 element->scale = {2, 2, 1}; | 120 element->scale = {2, 2, 1}; |
| 121 element->rotation = {0, 0, 1, M_PI / 2}; | 121 element->rotation = {0, 0, 1, M_PI / 2}; |
| 122 element->translation = {3, 0, 0}; | 122 element->translation = {3, 0, 0}; |
| 123 scene.AddUiElement(std::move(element)); | 123 scene.AddUiElement(std::move(element)); |
| 124 const ContentRectangle* child = scene.GetUiElementById(1); | 124 const ContentRectangle* child = scene.GetUiElementById(1); |
| 125 | 125 |
| 126 const gvr::Vec3f origin({0, 0, 0}); | 126 const gvr::Vec3f origin({0, 0, 0}); |
| 127 const gvr::Vec3f point({1, 0, 0}); | 127 const gvr::Vec3f point({1, 0, 0}); |
| 128 | 128 |
| 129 // Check resulting transform with no screen tilt. | |
| 130 scene.UpdateTransforms(0); | 129 scene.UpdateTransforms(0); |
| 131 auto new_origin = MatrixVectorMul(child->TransformMatrix(), origin); | 130 auto new_origin = MatrixVectorMul(child->TransformMatrix(), origin); |
| 132 auto new_point = MatrixVectorMul(child->TransformMatrix(), point); | 131 auto new_point = MatrixVectorMul(child->TransformMatrix(), point); |
| 133 EXPECT_VEC3F_NEAR(gvr::Vec3f({6, 10, 0}), new_origin); | 132 EXPECT_VEC3F_NEAR(gvr::Vec3f({6, 10, 0}), new_origin); |
| 134 EXPECT_VEC3F_NEAR(gvr::Vec3f({0, 10, 0}), new_point); | 133 EXPECT_VEC3F_NEAR(gvr::Vec3f({0, 10, 0}), new_point); |
| 135 } | 134 } |
| 136 | 135 |
| 137 TEST(UiScene, Opacity) { | 136 TEST(UiScene, Opacity) { |
| 138 UiScene scene; | 137 UiScene scene; |
| 139 | 138 |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 EXPECT_FLOAT_EQ(animation->from[0], 300); | 433 EXPECT_FLOAT_EQ(animation->from[0], 300); |
| 435 EXPECT_FLOAT_EQ(animation->from[1], 301); | 434 EXPECT_FLOAT_EQ(animation->from[1], 301); |
| 436 EXPECT_FLOAT_EQ(animation->from[2], 302); | 435 EXPECT_FLOAT_EQ(animation->from[2], 302); |
| 437 EXPECT_FLOAT_EQ(animation->from[3], 303); | 436 EXPECT_FLOAT_EQ(animation->from[3], 303); |
| 438 | 437 |
| 439 EXPECT_EQ(animation->start, 22345000); | 438 EXPECT_EQ(animation->start, 22345000); |
| 440 EXPECT_EQ(animation->duration, 54321000); | 439 EXPECT_EQ(animation->duration, 54321000); |
| 441 } | 440 } |
| 442 | 441 |
| 443 } // namespace vr_shell | 442 } // namespace vr_shell |
| OLD | NEW |