Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / remoting / webapp / base / js / platform_unittest.js
blob74e9763e7c1de9cd05fede88e48783dbc14b7da4
1 // Copyright 2015 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.
5 (function() {
7 'use strict';
9 var testData = [{
10 userAgent: 'Mozilla/5.0 (X11; CrOS x86_64 6457.107.0) AppleWebKit/537.36 ' +
11 '(KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36,gzip(gfe)',
12 osName: 'ChromeOS',
13 osVersion: '6457.107.0',
14 cpu: 'x86_64',
15 chromeVersion: '40.0.2214.115'
16 }, {
17 userAgent: 'Mozilla/5.0 (X11; CrOS i686 6812.88.0) AppleWebKit/537.36 ' +
18 '(KHTML, like Gecko) Chrome/42.0.2311.153 Safari/537.36,gzip(gfe)',
19 osName: 'ChromeOS',
20 osVersion: '6812.88.0',
21 cpu: 'i686',
22 chromeVersion: '42.0.2311.153'
23 }, {
24 userAgent: 'Mozilla/5.0 (X11; CrOS armv7l 6946.52.0) AppleWebKit/537.36 ' +
25 '(KHTML, like Gecko) Chrome/43.0.2357.73 Safari/537.36,gzip(gfe)',
26 osName: 'ChromeOS',
27 osVersion: '6946.52.0',
28 cpu: 'armv7l',
29 chromeVersion: '43.0.2357.73'
30 }, {
31 userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 ' +
32 '(KHTML, like Gecko) Chrome/45.0.2414.0 Safari/537.36,gzip(gfe)',
33 osName: 'Linux',
34 osVersion: '',
35 cpu: 'x86_64',
36 chromeVersion: '45.0.2414.0'
37 },{
38 userAgent: 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 ' +
39 '(KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36,gzip(gfe)',
40 osName: 'Windows',
41 osVersion: '6.1',
42 cpu: '',
43 chromeVersion: '43.0.2357.81'
44 },{
45 userAgent: 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 ' +
46 '(KHTML, like Gecko) Chrome/42.0.2311.152 Safari/537.36,gzip(gfe)',
47 osName: 'Windows',
48 osVersion: '6.3',
49 cpu: '',
50 chromeVersion: '42.0.2311.152'
51 },{
52 userAgent: 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 ' +
53 '(KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36,gzip(gfe)',
54 osName: 'Windows',
55 osVersion: '6.3',
56 cpu: '',
57 chromeVersion: '43.0.2357.81'
58 }, {
59 userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 '+
60 '(KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36,gzip(gfe)',
61 osName: 'Windows',
62 osVersion: '10.0',
63 cpu: '',
64 chromeVersion: '43.0.2357.81'
65 },{
66 userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit' +
67 '/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36,gzip(gfe)',
68 osName: 'Mac',
69 osVersion: '10.9.5',
70 cpu: 'Intel',
71 chromeVersion: '43.0.2357.81'
72 },{
73 userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit' +
74 '/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36,gzip(gfe)',
75 osName: 'Mac',
76 osVersion: '10.10.1',
77 cpu: 'Intel',
78 chromeVersion: '43.0.2357.81'
79 },{
80 userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit' +
81 '/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36,gzip(gfe)',
82 osName: 'Mac',
83 osVersion: '10.10.2',
84 cpu: 'Intel',
85 chromeVersion: '43.0.2357.81'
86 },{
87 userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit' +
88 '/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36,gzip(gfe)',
89 osName: 'Mac',
90 osVersion: '10.10.3',
91 cpu: 'Intel',
92 chromeVersion: '43.0.2357.81'
96 QUnit.module('platform');
98 function forEachUserAgent(/** function(Object<string>, string) */ callback) {
99 testData.forEach(function(/** Object<string>*/ testCase) {
100 var message = 'userAgent: ' + testCase['userAgent']
101 var userAgentStub = sinon.stub(remoting, 'getUserAgent');
102 userAgentStub.returns(testCase['userAgent']);
103 var result = remoting.getSystemInfo();
104 callback(testCase, message);
105 userAgentStub.restore();
109 QUnit.test('OS name, OS version, chrome version and cpu detection',
110 function(assert) {
111 forEachUserAgent(
112 function(/** Object<string> */ testCase, /** string */ message) {
113 var result = remoting.getSystemInfo();
114 assert.equal(result.osName, testCase['osName'], message);
115 assert.equal(result.osVersion, testCase['osVersion'], message);
116 assert.equal(result.cpu, testCase['cpu'], message);
117 assert.equal(result.chromeVersion, testCase['chromeVersion'], message);
121 QUnit.test('platform is Mac', function(assert) {
122 forEachUserAgent(
123 function(/** Object<string> */ testCase, /** string */ message) {
124 assert.equal(remoting.platformIsMac(),
125 testCase['osName'] === 'Mac', message);
129 QUnit.test('platform is Windows', function(assert) {
130 forEachUserAgent(
131 function(/** Object<string> */ testCase, /** string */ message) {
132 assert.equal(remoting.platformIsWindows(),
133 testCase['osName'] === 'Windows', message);
137 QUnit.test('platform is Linux', function(assert) {
138 forEachUserAgent(
139 function(/** Object<string> */ testCase, /** string */ message) {
140 assert.equal(remoting.platformIsLinux(),
141 testCase['osName'] === 'Linux', message);
145 QUnit.test('platform is ChromeOS', function(assert) {
146 forEachUserAgent(
147 function(/** Object<string> */ testCase, /** string */ message) {
148 assert.equal(remoting.platformIsChromeOS(),
149 testCase['osName'] === 'ChromeOS', message);
153 })();