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

Unified Diff: chrome/browser/android/vr_shell/ui_scene_unittest.cc

Issue 2668093002: VrShell background implemented in JS. (Closed)
Patch Set: Removed superfluous tests from previous patch set Created 3 years, 11 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: chrome/browser/android/vr_shell/ui_scene_unittest.cc
diff --git a/chrome/browser/android/vr_shell/ui_scene_unittest.cc b/chrome/browser/android/vr_shell/ui_scene_unittest.cc
index cdd0f3970e7c5c0adff83cdae5bc1b8e968c539d..cb6b2db881f99535b87565ae7533448e15db977a 100644
--- a/chrome/browser/android/vr_shell/ui_scene_unittest.cc
+++ b/chrome/browser/android/vr_shell/ui_scene_unittest.cc
@@ -75,15 +75,15 @@ TEST(UiScene, AddRemoveContentQuad) {
base::DictionaryValue dict;
dict.SetInteger("id", 0);
- dict.SetBoolean("contentQuad", true);
+ dict.SetInteger("fillType", Fill::CONTENT);
scene.AddUiElementFromDict(dict);
EXPECT_NE(scene.GetContentQuad(), nullptr);
- dict.SetBoolean("contentQuad", false);
+ dict.SetInteger("fillType", Fill::SPRITE);
scene.UpdateUiElementFromDict(dict);
EXPECT_EQ(scene.GetContentQuad(), nullptr);
- dict.SetBoolean("contentQuad", true);
+ dict.SetInteger("fillType", Fill::CONTENT);
scene.UpdateUiElementFromDict(dict);
EXPECT_NE(scene.GetContentQuad(), nullptr);
@@ -236,7 +236,7 @@ TEST(UiScene, AddUiElementFromDictionary) {
dict.SetBoolean("visible", false);
dict.SetBoolean("hitTestable", false);
dict.SetBoolean("lockToFov", true);
- dict.SetBoolean("contentQuad", true);
+ dict.SetInteger("fillType", Fill::SPRITE);
dict.SetInteger("xAnchoring", XAnchoring::XLEFT);
dict.SetInteger("yAnchoring", YAnchoring::YTOP);
dict.SetDouble("opacity", 0.357);
@@ -281,7 +281,7 @@ TEST(UiScene, AddUiElementFromDictionary) {
EXPECT_EQ(element->visible, false);
EXPECT_EQ(element->hit_testable, false);
EXPECT_EQ(element->lock_to_fov, true);
- EXPECT_EQ(element->content_quad, true);
+ EXPECT_EQ(element->fill, Fill::SPRITE);
EXPECT_EQ(element->x_anchoring, XAnchoring::XLEFT);
EXPECT_EQ(element->y_anchoring, YAnchoring::YTOP);
EXPECT_FLOAT_EQ(element->opacity, 0.357);
@@ -309,6 +309,92 @@ TEST(UiScene, AddUiElementFromDictionary) {
EXPECT_FLOAT_EQ(element->translation.z, 502);
}
+TEST(UiScene, AddUiElementFromDictionary_Fill) {
+ UiScene scene;
+ base::DictionaryValue dict;
+ constexpr double EPSILON = 0.000001;
cjgrant 2017/02/02 14:48:25 This can be removed (see below).
tiborg1 2017/02/02 16:52:27 Done.
+
+ base::DictionaryValue copy_rect;
+ copy_rect.SetInteger("x", 1);
+ copy_rect.SetInteger("y", 2);
+ copy_rect.SetInteger("width", 3);
+ copy_rect.SetInteger("height", 4);
+
+ base::DictionaryValue edge_color;
+ edge_color.SetDouble("r", 0.1);
+ edge_color.SetDouble("g", 0.2);
+ edge_color.SetDouble("b", 0.3);
+ edge_color.SetDouble("a", 0.4);
+
+ base::DictionaryValue center_color;
+ center_color.SetDouble("r", 0.5);
+ center_color.SetDouble("g", 0.6);
+ center_color.SetDouble("b", 0.7);
+ center_color.SetDouble("a", 0.8);
+
+ // Test SPRITE filling.
+ dict.SetInteger("id", 9);
+ dict.SetInteger("fillType", Fill::SPRITE);
+ dict.Set("copyRect", copy_rect.DeepCopy());
+ scene.AddUiElementFromDict(dict);
+ const auto* element = scene.GetUiElementById(9);
+
+ EXPECT_EQ(element->fill, Fill::SPRITE);
+ EXPECT_EQ(element->copy_rect.x, 1);
+ EXPECT_EQ(element->copy_rect.y, 2);
+ EXPECT_EQ(element->copy_rect.width, 3);
+ EXPECT_EQ(element->copy_rect.height, 4);
+
+ // Test OPAQUE_GRADIENT filling.
+ dict.Clear();
+ dict.SetInteger("id", 10);
+ dict.SetInteger("fillType", Fill::OPAQUE_GRADIENT);
+ dict.Set("edgeColor", edge_color.DeepCopy());
+ dict.Set("centerColor", center_color.DeepCopy());
+ scene.AddUiElementFromDict(dict);
+ element = scene.GetUiElementById(10);
+
+ EXPECT_EQ(element->fill, Fill::OPAQUE_GRADIENT);
+ EXPECT_NEAR(element->edge_color.r, 0.1, EPSILON);
cjgrant 2017/02/02 14:48:25 I think you want EXPECT_FLOAT_EQ() for these cases
tiborg1 2017/02/02 16:52:27 Oh yes, this makes it way more elegant :) Done.
+ EXPECT_NEAR(element->edge_color.g, 0.2, EPSILON);
+ EXPECT_NEAR(element->edge_color.b, 0.3, EPSILON);
+ EXPECT_NEAR(element->edge_color.a, 0.4, EPSILON);
+ EXPECT_NEAR(element->center_color.r, 0.5, EPSILON);
+ EXPECT_NEAR(element->center_color.g, 0.6, EPSILON);
+ EXPECT_NEAR(element->center_color.b, 0.7, EPSILON);
+ EXPECT_NEAR(element->center_color.a, 0.8, EPSILON);
+
+ // Test GRID_GRADIENT filling.
+ dict.Clear();
+ dict.SetInteger("id", 11);
+ dict.SetInteger("fillType", Fill::GRID_GRADIENT);
+ dict.Set("edgeColor", edge_color.DeepCopy());
+ dict.Set("centerColor", center_color.DeepCopy());
+ dict.SetInteger("tileNumber", 10);
+ scene.AddUiElementFromDict(dict);
+ element = scene.GetUiElementById(11);
+
+ EXPECT_EQ(element->fill, Fill::GRID_GRADIENT);
+ EXPECT_NEAR(element->edge_color.r, 0.1, EPSILON);
+ EXPECT_NEAR(element->edge_color.g, 0.2, EPSILON);
+ EXPECT_NEAR(element->edge_color.b, 0.3, EPSILON);
+ EXPECT_NEAR(element->edge_color.a, 0.4, EPSILON);
+ EXPECT_NEAR(element->center_color.r, 0.5, EPSILON);
+ EXPECT_NEAR(element->center_color.g, 0.6, EPSILON);
+ EXPECT_NEAR(element->center_color.b, 0.7, EPSILON);
+ EXPECT_NEAR(element->center_color.a, 0.8, EPSILON);
+ EXPECT_EQ(element->tile_number, 10u);
+
+ // Test CONTENT filling.
+ dict.Clear();
+ dict.SetInteger("id", 12);
+ dict.SetInteger("fillType", Fill::CONTENT);
+ scene.AddUiElementFromDict(dict);
+ element = scene.GetUiElementById(12);
+
+ EXPECT_EQ(element->fill, Fill::CONTENT);
+}
+
TEST(UiScene, AddAnimationFromDictionary) {
UiScene scene;
addElement(&scene, 0);

Powered by Google App Engine
This is Rietveld 408576698