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

Side by Side Diff: chrome/browser/android/vr_shell/ui_scene_unittest.cc

Issue 2698623007: Change how the VR reticle distance is determined. (Closed)
Patch Set: Change background distance multplier to 1.414; move Reload UI button out of the floor. Created 3 years, 10 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
OLDNEW
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 EXPECT_EQ(scene.GetUiElementById(0), nullptr); 62 EXPECT_EQ(scene.GetUiElementById(0), nullptr);
63 scene.RemoveUiElement(99); 63 scene.RemoveUiElement(99);
64 EXPECT_EQ(scene.GetUiElements().size(), 0u); 64 EXPECT_EQ(scene.GetUiElements().size(), 0u);
65 EXPECT_EQ(scene.GetUiElementById(99), nullptr); 65 EXPECT_EQ(scene.GetUiElementById(99), nullptr);
66 66
67 scene.RemoveUiElement(0); 67 scene.RemoveUiElement(0);
68 scene.RemoveUiElement(99); 68 scene.RemoveUiElement(99);
69 EXPECT_EQ(scene.GetUiElements().size(), 0u); 69 EXPECT_EQ(scene.GetUiElements().size(), 0u);
70 } 70 }
71 71
72 TEST(UiScene, AddRemoveContentQuad) {
73 UiScene scene;
74
75 EXPECT_EQ(scene.GetContentQuad(), nullptr);
76
77 base::DictionaryValue dict;
78 dict.SetInteger("id", 0);
79 dict.SetInteger("fillType", Fill::CONTENT);
80 scene.AddUiElementFromDict(dict);
81 EXPECT_NE(scene.GetContentQuad(), nullptr);
82
83 dict.SetInteger("fillType", Fill::SPRITE);
84 std::unique_ptr<base::DictionaryValue> copy_rect(new base::DictionaryValue);
85 copy_rect->SetInteger("x", 100);
86 copy_rect->SetInteger("y", 101);
87 copy_rect->SetInteger("width", 102);
88 copy_rect->SetInteger("height", 103);
89 dict.Set("copyRect", std::move(copy_rect));
90 scene.UpdateUiElementFromDict(dict);
91 EXPECT_EQ(scene.GetContentQuad(), nullptr);
92
93 dict.SetInteger("fillType", Fill::CONTENT);
94 scene.UpdateUiElementFromDict(dict);
95 EXPECT_NE(scene.GetContentQuad(), nullptr);
96
97 scene.RemoveUiElement(0);
98 EXPECT_EQ(scene.GetContentQuad(), nullptr);
99 }
100
101 TEST(UiScene, AddRemoveAnimations) { 72 TEST(UiScene, AddRemoveAnimations) {
102 UiScene scene; 73 UiScene scene;
103 addElement(&scene, 0); 74 addElement(&scene, 0);
104 auto *element = scene.GetUiElementById(0); 75 auto *element = scene.GetUiElementById(0);
105 76
106 EXPECT_EQ(element->animations.size(), 0u); 77 EXPECT_EQ(element->animations.size(), 0u);
107 addAnimation(&scene, 0, 0, Animation::Property::SIZE); 78 addAnimation(&scene, 0, 0, Animation::Property::SIZE);
108 EXPECT_EQ(element->animations.size(), 1u); 79 EXPECT_EQ(element->animations.size(), 1u);
109 EXPECT_EQ(element->animations[0]->property, Animation::Property::SIZE); 80 EXPECT_EQ(element->animations[0]->property, Animation::Property::SIZE);
110 addAnimation(&scene, 0, 1, Animation::Property::SCALE); 81 addAnimation(&scene, 0, 1, Animation::Property::SCALE);
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 EXPECT_FLOAT_EQ(animation->from[0], 300); 421 EXPECT_FLOAT_EQ(animation->from[0], 300);
451 EXPECT_FLOAT_EQ(animation->from[1], 301); 422 EXPECT_FLOAT_EQ(animation->from[1], 301);
452 EXPECT_FLOAT_EQ(animation->from[2], 302); 423 EXPECT_FLOAT_EQ(animation->from[2], 302);
453 EXPECT_FLOAT_EQ(animation->from[3], 303); 424 EXPECT_FLOAT_EQ(animation->from[3], 303);
454 425
455 EXPECT_EQ(animation->start, 22345000); 426 EXPECT_EQ(animation->start, 22345000);
456 EXPECT_EQ(animation->duration, 54321000); 427 EXPECT_EQ(animation->duration, 54321000);
457 } 428 }
458 429
459 } // namespace vr_shell 430 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/ui_scene.cc ('k') | chrome/browser/android/vr_shell/vr_shell_gl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698