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

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

Issue 2706343005: Allow individual UI element properties to be modified. (Closed)
Patch Set: Use a safer cast on integer conversions. Created 3 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 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 dict.SetInteger("id", 10); 215 dict.SetInteger("id", 10);
216 dict.SetInteger("parentId", 11); 216 dict.SetInteger("parentId", 11);
217 dict.SetBoolean("visible", false); 217 dict.SetBoolean("visible", false);
218 dict.SetBoolean("hitTestable", false); 218 dict.SetBoolean("hitTestable", false);
219 dict.SetBoolean("lockToFov", true); 219 dict.SetBoolean("lockToFov", true);
220 dict.SetInteger("fillType", Fill::SPRITE); 220 dict.SetInteger("fillType", Fill::SPRITE);
221 dict.SetInteger("xAnchoring", XAnchoring::XLEFT); 221 dict.SetInteger("xAnchoring", XAnchoring::XLEFT);
222 dict.SetInteger("yAnchoring", YAnchoring::YTOP); 222 dict.SetInteger("yAnchoring", YAnchoring::YTOP);
223 dict.SetDouble("opacity", 0.357); 223 dict.SetDouble("opacity", 0.357);
224 224
225 std::unique_ptr<base::DictionaryValue> copy_rect(new base::DictionaryValue); 225 dict.SetInteger("copyRectX", 100);
226 copy_rect->SetInteger("x", 100); 226 dict.SetInteger("copyRectY", 101);
227 copy_rect->SetInteger("y", 101); 227 dict.SetInteger("copyRectWidth", 102);
228 copy_rect->SetInteger("width", 102); 228 dict.SetInteger("copyRectHeight", 103);
229 copy_rect->SetInteger("height", 103);
230 dict.Set("copyRect", std::move(copy_rect));
231 229
232 std::unique_ptr<base::DictionaryValue> size(new base::DictionaryValue); 230 dict.SetDouble("sizeX", 200);
233 size->SetDouble("x", 200); 231 dict.SetDouble("sizeY", 201);
234 size->SetDouble("y", 201);
235 dict.Set("size", std::move(size));
236 232
237 std::unique_ptr<base::DictionaryValue> scale(new base::DictionaryValue); 233 dict.SetDouble("scaleX", 300);
238 scale->SetDouble("x", 300); 234 dict.SetDouble("scaleY", 301);
239 scale->SetDouble("y", 301); 235 dict.SetDouble("scaleZ", 302);
240 scale->SetDouble("z", 302);
241 dict.Set("scale", std::move(scale));
242 236
243 std::unique_ptr<base::DictionaryValue> rotation(new base::DictionaryValue); 237 dict.SetDouble("rotationX", 400);
244 rotation->SetDouble("x", 400); 238 dict.SetDouble("rotationY", 401);
245 rotation->SetDouble("y", 401); 239 dict.SetDouble("rotationZ", 402);
246 rotation->SetDouble("z", 402); 240 dict.SetDouble("rotationAngle", 403);
247 rotation->SetDouble("a", 403);
248 dict.Set("rotation", std::move(rotation));
249 241
250 std::unique_ptr<base::DictionaryValue> translation(new base::DictionaryValue); 242 dict.SetDouble("translationX", 500);
251 translation->SetDouble("x", 500); 243 dict.SetDouble("translationY", 501);
252 translation->SetDouble("y", 501); 244 dict.SetDouble("translationZ", 502);
253 translation->SetDouble("z", 502);
254 dict.Set("translation", std::move(translation));
255 245
256 scene.AddUiElementFromDict(dict); 246 scene.AddUiElementFromDict(dict);
257 const auto* element = scene.GetUiElementById(10); 247 const auto* element = scene.GetUiElementById(10);
258 EXPECT_NE(element, nullptr); 248 EXPECT_NE(element, nullptr);
259 249
260 EXPECT_EQ(element->id, 10); 250 EXPECT_EQ(element->id, 10);
261 EXPECT_EQ(element->parent_id, 11); 251 EXPECT_EQ(element->parent_id, 11);
262 EXPECT_EQ(element->visible, false); 252 EXPECT_EQ(element->visible, false);
263 EXPECT_EQ(element->hit_testable, false); 253 EXPECT_EQ(element->hit_testable, false);
264 EXPECT_EQ(element->lock_to_fov, true); 254 EXPECT_EQ(element->lock_to_fov, true);
(...skipping 22 matching lines...) Expand all
287 277
288 EXPECT_FLOAT_EQ(element->translation.x, 500); 278 EXPECT_FLOAT_EQ(element->translation.x, 500);
289 EXPECT_FLOAT_EQ(element->translation.y, 501); 279 EXPECT_FLOAT_EQ(element->translation.y, 501);
290 EXPECT_FLOAT_EQ(element->translation.z, 502); 280 EXPECT_FLOAT_EQ(element->translation.z, 502);
291 } 281 }
292 282
293 TEST(UiScene, AddUiElementFromDictionary_Fill) { 283 TEST(UiScene, AddUiElementFromDictionary_Fill) {
294 UiScene scene; 284 UiScene scene;
295 base::DictionaryValue dict; 285 base::DictionaryValue dict;
296 286
297 base::DictionaryValue copy_rect; 287 dict.SetInteger("copyRectX", 1);
298 copy_rect.SetInteger("x", 1); 288 dict.SetInteger("copyRectY", 2);
299 copy_rect.SetInteger("y", 2); 289 dict.SetInteger("copyRectWidth", 3);
300 copy_rect.SetInteger("width", 3); 290 dict.SetInteger("copyRectHeight", 4);
301 copy_rect.SetInteger("height", 4);
302 291
303 base::DictionaryValue edge_color; 292 base::DictionaryValue edge_color;
304 edge_color.SetDouble("r", 0.1); 293 edge_color.SetDouble("r", 0.1);
305 edge_color.SetDouble("g", 0.2); 294 edge_color.SetDouble("g", 0.2);
306 edge_color.SetDouble("b", 0.3); 295 edge_color.SetDouble("b", 0.3);
307 edge_color.SetDouble("a", 0.4); 296 edge_color.SetDouble("a", 0.4);
308 297
309 base::DictionaryValue center_color; 298 base::DictionaryValue center_color;
310 center_color.SetDouble("r", 0.5); 299 center_color.SetDouble("r", 0.5);
311 center_color.SetDouble("g", 0.6); 300 center_color.SetDouble("g", 0.6);
312 center_color.SetDouble("b", 0.7); 301 center_color.SetDouble("b", 0.7);
313 center_color.SetDouble("a", 0.8); 302 center_color.SetDouble("a", 0.8);
314 303
315 // Test SPRITE filling. 304 // Test SPRITE filling.
316 dict.SetInteger("id", 9); 305 dict.SetInteger("id", 9);
317 dict.SetInteger("fillType", Fill::SPRITE); 306 dict.SetInteger("fillType", Fill::SPRITE);
318 dict.Set("copyRect", copy_rect.DeepCopy());
319 scene.AddUiElementFromDict(dict); 307 scene.AddUiElementFromDict(dict);
320 const auto* element = scene.GetUiElementById(9); 308 const auto* element = scene.GetUiElementById(9);
321 309
322 EXPECT_EQ(element->fill, Fill::SPRITE); 310 EXPECT_EQ(element->fill, Fill::SPRITE);
323 EXPECT_EQ(element->copy_rect.x, 1); 311 EXPECT_EQ(element->copy_rect.x, 1);
324 EXPECT_EQ(element->copy_rect.y, 2); 312 EXPECT_EQ(element->copy_rect.y, 2);
325 EXPECT_EQ(element->copy_rect.width, 3); 313 EXPECT_EQ(element->copy_rect.width, 3);
326 EXPECT_EQ(element->copy_rect.height, 4); 314 EXPECT_EQ(element->copy_rect.height, 4);
327 315
328 // Test OPAQUE_GRADIENT filling. 316 // Test OPAQUE_GRADIENT filling.
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 EXPECT_FLOAT_EQ(animation->from[0], 300); 412 EXPECT_FLOAT_EQ(animation->from[0], 300);
425 EXPECT_FLOAT_EQ(animation->from[1], 301); 413 EXPECT_FLOAT_EQ(animation->from[1], 301);
426 EXPECT_FLOAT_EQ(animation->from[2], 302); 414 EXPECT_FLOAT_EQ(animation->from[2], 302);
427 EXPECT_FLOAT_EQ(animation->from[3], 303); 415 EXPECT_FLOAT_EQ(animation->from[3], 303);
428 416
429 EXPECT_EQ(animation->start, 22345000); 417 EXPECT_EQ(animation->start, 22345000);
430 EXPECT_EQ(animation->duration, 54321000); 418 EXPECT_EQ(animation->duration, 54321000);
431 } 419 }
432 420
433 } // namespace vr_shell 421 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/ui_scene.cc ('k') | chrome/browser/resources/vr_shell/vr_shell_ui_api.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698