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

Unified Diff: tools/cc-frame-viewer/src/base/color_test.html

Issue 12225131: [cc] Initial checkin of cc-frame-viewer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/cc-frame-viewer/src/base/color.js ('k') | tools/cc-frame-viewer/src/base/deps.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/cc-frame-viewer/src/base/color_test.html
diff --git a/tools/cc-frame-viewer/src/base/color_test.html b/tools/cc-frame-viewer/src/base/color_test.html
new file mode 100644
index 0000000000000000000000000000000000000000..aafc528c0ec859803e5a2675783c39ffc57a185b
--- /dev/null
+++ b/tools/cc-frame-viewer/src/base/color_test.html
@@ -0,0 +1,73 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+Copyright (c) 2012 The Chromium Authors. All rights reserved.
+Use of this source code is governed by a BSD-style license that can be
+found in the LICENSE file.
+-->
+<head>
+<script src="../base.js"></script>
+<script>
+ base.require('base.unittest');
+ base.require('base.color');
+</script>
+</head>
+<body>
+<script>
+ 'use strict';
+
+ var Color = base.Color;
+
+ function testFromRGB() {
+ var c = Color.fromString('rgb(1, 2, 3)');
+ assertEquals(1, c.r);
+ assertEquals(2, c.g);
+ assertEquals(3, c.b);
+ assertEquals(undefined, c.a);
+ }
+ function testFromString() {
+ var c = Color.fromString('rgba(1, 2, 3, 0.5)');
+ assertEquals(1, c.r);
+ assertEquals(2, c.g);
+ assertEquals(3, c.b);
+ assertEquals(0.5, c.a);
+ }
+ function testFromString() {
+ var c = Color.fromString('#010203');
+ assertEquals(1, c.r);
+ assertEquals(2, c.g);
+ assertEquals(3, c.b);
+ assertEquals(undefined, c.a);
+ }
+
+ function testToStringRGB() {
+ var c = new Color(1, 2, 3);
+ assertEquals('rgb(1,2,3)', c.toString());
+ }
+
+ function testToStringRGBA() {
+ var c = new Color(1, 2, 3, 0.5);
+ assertEquals('rgba(1,2,3,0.5)', c.toString());
+ }
+
+ function testLerpRGB() {
+ var a = new Color(0, 127, 191);
+ var b = new Color(255, 255, 255);
+ var x = Color.lerpRGB(a, b, 0.25);
+ assertEquals(63, x.r);
+ assertEquals(159, x.g);
+ assertEquals(207, x.b);
+ }
+
+ function testLerpRGBA() {
+ var a = new Color(0, 127, 191, 0.5);
+ var b = new Color(255, 255, 255, 1);
+ var x = Color.lerpRGBA(a, b, 0.25);
+ assertEquals(63, x.r);
+ assertEquals(159, x.g);
+ assertEquals(207, x.b);
+ assertEquals(0.625, x.a);
+ }
+</script>
+</body>
+</html>
« no previous file with comments | « tools/cc-frame-viewer/src/base/color.js ('k') | tools/cc-frame-viewer/src/base/deps.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698