| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |