Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 (function() { | |
| 6 | |
| 7 'use strict'; | |
| 8 | |
| 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 os_name: 'ChromeOS', | |
| 13 os_version: '6457.107.0', | |
| 14 cpu: 'x86_64', | |
| 15 chrome_version: '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 os_name: 'ChromeOS', | |
| 20 os_version: '6812.88.0', | |
| 21 cpu: 'i686', | |
| 22 chrome_version: '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 os_name: 'ChromeOS', | |
| 27 os_version: '6946.52.0', | |
| 28 cpu: 'armv7l', | |
| 29 chrome_version: '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 os_name: 'Linux', | |
| 34 os_version: '', | |
| 35 cpu: 'x86_64', | |
| 36 chrome_version: '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 os_name: 'Windows', | |
| 41 os_version: '6.1', | |
| 42 cpu: '', | |
| 43 chrome_version: '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 os_name: 'Windows', | |
| 48 os_version: '6.3', | |
| 49 cpu: '', | |
| 50 chrome_version: '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 os_name: 'Windows', | |
| 55 os_version: '6.3', | |
| 56 cpu: '', | |
| 57 chrome_version: '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 os_name: 'Windows', | |
| 62 os_version: '10.0', | |
| 63 cpu: '', | |
| 64 chrome_version: '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 os_name: 'Mac', | |
| 69 os_version: '10.9.5', | |
| 70 cpu: 'Intel', | |
| 71 chrome_version: '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 os_name: 'Mac', | |
| 76 os_version: '10.10.1', | |
| 77 cpu: 'Intel', | |
| 78 chrome_version: '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 os_name: 'Mac', | |
| 83 os_version: '10.10.2', | |
| 84 cpu: 'Intel', | |
| 85 chrome_version: '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 os_name: 'Mac', | |
| 90 os_version: '10.10.3', | |
| 91 cpu: 'Intel', | |
| 92 chrome_version: '43.0.2357.81' | |
| 93 } | |
| 94 ]; | |
| 95 | |
| 96 QUnit.module('platform'); | |
| 97 | |
| 98 function forEachTest(/** function(Object<string>, string) */ callback) { | |
|
Jamie
2015/06/06 01:05:41
This should be called something like "forEachUserA
kelvinp
2015/06/06 02:09:54
Done.
| |
| 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(); | |
| 106 }); | |
| 107 } | |
| 108 | |
| 109 QUnit.test('OS name, OS version, chrome version and cpu detection', | |
| 110 function(assert) { | |
| 111 forEachTest(function(/** Object<string> */ testCase, /** string */ message) { | |
| 112 var result = remoting.getSystemInfo(); | |
| 113 assert.equal(result.os_name, testCase['os_name'], message); | |
| 114 assert.equal(result.os_version, testCase['os_version'], message); | |
| 115 assert.equal(result.cpu, testCase['cpu'], message); | |
| 116 assert.equal(result.chrome_version, testCase['chrome_version'], message); | |
| 117 }); | |
| 118 }); | |
| 119 | |
| 120 QUnit.test('platform is Mac', function(assert) { | |
| 121 forEachTest(function(/** Object<string> */ testCase, /** string */ message) { | |
| 122 assert.equal(remoting.platformIsMac(), | |
| 123 testCase['os_name'] === 'Mac', message); | |
| 124 }); | |
| 125 }); | |
| 126 | |
| 127 QUnit.test('platform is Windows', function(assert) { | |
| 128 forEachTest(function(/** Object<string> */ testCase, /** string */ message) { | |
| 129 assert.equal(remoting.platformIsWindows(), | |
| 130 testCase['os_name'] === 'Windows', message); | |
| 131 }); | |
| 132 }); | |
| 133 | |
| 134 QUnit.test('platform is Linux', function(assert) { | |
| 135 forEachTest(function(/** Object<string> */ testCase, /** string */ message) { | |
| 136 assert.equal(remoting.platformIsLinux(), | |
| 137 testCase['os_name'] === 'Linux', message); | |
| 138 }); | |
| 139 }); | |
| 140 | |
| 141 QUnit.test('platform is ChromeOS', function(assert) { | |
| 142 forEachTest(function(/** Object<string> */ testCase, /** string */ message) { | |
| 143 assert.equal(remoting.platformIsChromeOS(), | |
| 144 testCase['os_name'] === 'ChromeOS', message); | |
| 145 }); | |
| 146 }); | |
| 147 | |
| 148 })(); | |
| OLD | NEW |