OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // The extension ID for the .../activity_log_private/friend extension, which | 5 // The extension ID for the .../activity_log_private/friend extension, which |
6 // this extension communicates with. This should correspond to the public key | 6 // this extension communicates with. This should correspond to the public key |
7 // defined in .../activity_log_private/friend/manifest.json. | 7 // defined in .../activity_log_private/friend/manifest.json. |
8 var FRIEND_EXTENSION_ID = 'pknkgggnfecklokoggaggchhaebkajji'; | 8 var FRIEND_EXTENSION_ID = 'pknkgggnfecklokoggaggchhaebkajji'; |
9 | 9 |
10 // Setup the test cases. | 10 // Setup the test cases. |
(...skipping 21 matching lines...) Expand all Loading... |
32 'double', function response() {}); | 32 'double', function response() {}); |
33 }, | 33 }, |
34 expected_activity: ['omnibox.setDefaultSuggestion'] | 34 expected_activity: ['omnibox.setDefaultSuggestion'] |
35 }); | 35 }); |
36 testCases.push({ | 36 testCases.push({ |
37 func: function triggerAppBindings() { | 37 func: function triggerAppBindings() { |
38 chrome.runtime.sendMessage(FRIEND_EXTENSION_ID, | 38 chrome.runtime.sendMessage(FRIEND_EXTENSION_ID, |
39 'app_bindings', function response() { }); | 39 'app_bindings', function response() { }); |
40 }, | 40 }, |
41 expected_activity: [ | 41 expected_activity: [ |
42 'app.GetDetails', | 42 // These API calls show up differently depending on whether native bindings |
43 'app.GetIsInstalled', | 43 // are enabled. |
44 'app.getInstallState' | 44 /app\.[gG]etDetails/, |
| 45 /app\.[gG]etIsInstalled/, |
| 46 /app\.(getI|i)nstallState/, |
45 ] | 47 ] |
46 }); | 48 }); |
47 testCases.push({ | 49 testCases.push({ |
48 func: function triggerObjectMethods() { | 50 func: function triggerObjectMethods() { |
49 chrome.runtime.sendMessage(FRIEND_EXTENSION_ID, | 51 chrome.runtime.sendMessage(FRIEND_EXTENSION_ID, |
50 'object_methods', function response() { }); | 52 'object_methods', function response() { }); |
51 }, | 53 }, |
52 expected_activity: ['storage.clear'] | 54 expected_activity: ['storage.clear'] |
53 }); | 55 }); |
54 testCases.push({ | 56 testCases.push({ |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 if (blinkArgs[apiCall]) | 477 if (blinkArgs[apiCall]) |
476 args = args.splice(0, blinkArgs[apiCall] - 1); | 478 args = args.splice(0, blinkArgs[apiCall] - 1); |
477 apiCall += ' ' + args.join(' '); | 479 apiCall += ' ' + args.join(' '); |
478 } | 480 } |
479 expectedCall = 'runtime.onMessageExternal'; | 481 expectedCall = 'runtime.onMessageExternal'; |
480 var testCase = enabledTestCases[testCaseIndx]; | 482 var testCase = enabledTestCases[testCaseIndx]; |
481 if (callIndx > -1) { | 483 if (callIndx > -1) { |
482 expectedCall = testCase.expected_activity[callIndx]; | 484 expectedCall = testCase.expected_activity[callIndx]; |
483 } | 485 } |
484 console.log('Logged:' + apiCall + ' Expected:' + expectedCall); | 486 console.log('Logged:' + apiCall + ' Expected:' + expectedCall); |
485 chrome.test.assertEq(expectedCall, apiCall); | 487 // Allow either a RegExp or a strict string comparison. |
| 488 if (expectedCall instanceof RegExp) |
| 489 chrome.test.assertTrue(expectedCall.test(apiCall)); |
| 490 else |
| 491 chrome.test.assertEq(expectedCall, apiCall); |
486 | 492 |
487 // Check that no real URLs are logged in incognito-mode tests. Ignore | 493 // Check that no real URLs are logged in incognito-mode tests. Ignore |
488 // the initial call to windows.create opening the tab. | 494 // the initial call to windows.create opening the tab. |
489 if (apiCall != 'windows.create') { | 495 if (apiCall != 'windows.create') { |
490 checkIncognito(activity['pageUrl'], testCase.is_incognito); | 496 checkIncognito(activity['pageUrl'], testCase.is_incognito); |
491 checkIncognito(activity['argUrl'], testCase.is_incognito); | 497 checkIncognito(activity['argUrl'], testCase.is_incognito); |
492 } | 498 } |
493 | 499 |
494 // If all the expected calls have been logged for this test case then | 500 // If all the expected calls have been logged for this test case then |
495 // mark as suceeded and move to the next. Otherwise look for the next | 501 // mark as suceeded and move to the next. Otherwise look for the next |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 enabledTestCase[activityListForOS]; | 534 enabledTestCase[activityListForOS]; |
529 } | 535 } |
530 enabledTestCases.push(enabledTestCase); | 536 enabledTestCases.push(enabledTestCase); |
531 } | 537 } |
532 } | 538 } |
533 chrome.test.runTests(tests); | 539 chrome.test.runTests(tests); |
534 }); | 540 }); |
535 } | 541 } |
536 | 542 |
537 setupTestCasesAndRun(); | 543 setupTestCasesAndRun(); |
OLD | NEW |