1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 base.require('base.unittest');
8 base.require('base.raf');
10 base.unittest.testSuite('base.unittest', function() {
11 test('dpiAware', function() {
12 var currentDevicePixelRatio = window.devicePixelRatio;
13 var alternateDevicePixelRatio =
14 currentDevicePixelRatio > 1 ? currentDevicePixelRatio : 2;
18 var suite = function() {
19 test('dpiTest', function() {
20 dpi.push(window.devicePixelRatio);
21 names.push(this.name);
25 var ts = new base.unittest.TestSuite_('dpiTest Suite', suite);
27 ts.runTests([]).then(function(ignored) {
28 assertEquals(2, ts.testCount);
29 assertArrayEquals([1, alternateDevicePixelRatio], dpi.sort());
30 assertArrayEquals(['dpiTest_hiDPI', 'dpiTest_loDPI'], names.sort());
32 // Verify we reset back to the default value.
33 assertEquals(currentDevicePixelRatio, window.devicePixelRatio);
37 test('promise', function() {
38 return new Promise(function(r) {
43 test('async', function() {
44 return new Promise(function(r) {
45 base.requestAnimationFrame(function() {
51 /* To test failures remove comments
52 test('fail', function() {
53 assertEquals(true, false);
56 test('rejected-promise', function() {
57 return new Promise(function(resolver){
58 resolver.reject("Failure by rejection");
62 test('promise-that-throws-after-resolver', function() {
63 return new Promise(function(resolver){
64 throw new Error('blah');