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

Side by Side Diff: chrome/test/data/extensions/api_test/systeminfo/cpu/test_cpu_api.js

Issue 16295015: Remove onUpdate from systemInfo.cpu API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 6 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 unified diff | Download patch
« no previous file with comments | « chrome/common/extensions/api/system_info_cpu.idl ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // systeminfo.cpu api test 5 // systeminfo.cpu api test
6 // browser_tests.exe --gtest_filter=SystemInfoCpuApiTest.* 6 // browser_tests.exe --gtest_filter=SystemInfoCpuApiTest.*
7 7
8 var userStep = 3;
9 var kernelStep = 2;
10 var idleStep = 1;
11 function calculateUsage(count) {
12 return (100 - idleStep * 100/(userStep + kernelStep + idleStep));
13 }
14
15 chrome.test.runTests([ 8 chrome.test.runTests([
16 function testGet() { 9 function testGet() {
17 for(var i = 0; i < 20; ++i) { 10 for(var i = 0; i < 20; ++i) {
18 chrome.systemInfo.cpu.get(chrome.test.callbackPass(function(result) { 11 chrome.systemInfo.cpu.get(chrome.test.callbackPass(function(result) {
19 chrome.test.assertEq(4, result.numOfProcessors); 12 chrome.test.assertEq(4, result.numOfProcessors);
20 chrome.test.assertEq("x86", result.archName); 13 chrome.test.assertEq("x86", result.archName);
21 chrome.test.assertEq("unknown", result.modelName); 14 chrome.test.assertEq("unknown", result.modelName);
22 })); 15 }));
23 } 16 }
24 },
25
26 function testUpdatedEvent() {
27 var numOfUpdatedEvent = 0;
28 var doneUpdatedEvent = chrome.test.listenForever(
29 chrome.systemInfo.cpu.onUpdated,
30 function listener(updateInfo) {
31 var expectedUsage = calculateUsage(numOfUpdatedEvent);
32 chrome.test.assertEq(updateInfo.averageUsage, expectedUsage);
33
34 chrome.test.assertEq(updateInfo.usagePerProcessor.length, 4);
35 for (var i = 0; i < updateInfo.usagePerProcessor.length; ++i)
36 chrome.test.assertEq(updateInfo.usagePerProcessor[i], expectedUsage);
37 if (++numOfUpdatedEvent > 5)
38 doneUpdatedEvent();
39 });
40 } 17 }
41 ]); 18 ]);
42 19
OLDNEW
« no previous file with comments | « chrome/common/extensions/api/system_info_cpu.idl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698