1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
// Copyright (c) 2013 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.
'use strict';
base.require('base.unittest');
base.require('base.raf');
base.unittest.testSuite('base.unittest', function() {
test('dpiAware', function() {
var currentDevicePixelRatio = window.devicePixelRatio;
var alternateDevicePixelRatio =
currentDevicePixelRatio > 1 ? currentDevicePixelRatio : 2;
var dpi = [];
var names = [];
var suite = function() {
test('dpiTest', function() {
dpi.push(window.devicePixelRatio);
names.push(this.name);
}, {dpiAware: true});
};
var ts = new base.unittest.TestSuite_('dpiTest Suite', suite);
ts.displayInfo();
ts.runTests([]).then(function(ignored) {
assertEquals(2, ts.testCount);
assertArrayEquals([1, alternateDevicePixelRatio], dpi.sort());
assertArrayEquals(['dpiTest_hiDPI', 'dpiTest_loDPI'], names.sort());
// Verify we reset back to the default value.
assertEquals(currentDevicePixelRatio, window.devicePixelRatio);
});
});
test('promise', function() {
return new Promise(function(r) {
r.resolve();
});
});
test('async', function() {
return new Promise(function(r) {
base.requestAnimationFrame(function() {
r.resolve();
});
});
});
/* To test failures remove comments
test('fail', function() {
assertEquals(true, false);
});
test('rejected-promise', function() {
return new Promise(function(resolver){
resolver.reject("Failure by rejection");
});
});
test('promise-that-throws-after-resolver', function() {
return new Promise(function(resolver){
throw new Error('blah');
});
});
*/
});
|