OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 GEN_INCLUDE([ | |
6 'chrome/browser/resources/chromeos/chromevox/testing/common.js']); | |
7 | |
5 /** | 8 /** |
6 * Base test fixture for ChromeVox end to end tests. | 9 * Base test fixture for ChromeVox end to end tests. |
7 * | 10 * |
8 * These tests run against production ChromeVox inside of the extension's | 11 * These tests run against production ChromeVox inside of the extension's |
9 * background page context. | 12 * background page context. |
10 * @constructor | 13 * @constructor |
11 */ | 14 */ |
12 function ChromeVoxE2ETest() {} | 15 function ChromeVoxE2ETest() {} |
13 | 16 |
14 ChromeVoxE2ETest.prototype = { | 17 ChromeVoxE2ETest.prototype = { |
(...skipping 30 matching lines...) Expand all Loading... | |
45 ash::A11Y_NOTIFICATION_NONE); | 48 ash::A11Y_NOTIFICATION_NONE); |
46 } | 49 } |
47 | 50 |
48 base::Closure load_cb = | 51 base::Closure load_cb = |
49 base::Bind(&chromeos::AccessibilityManager::EnableSpokenFeedback, | 52 base::Bind(&chromeos::AccessibilityManager::EnableSpokenFeedback, |
50 base::Unretained(chromeos::AccessibilityManager::Get()), | 53 base::Unretained(chromeos::AccessibilityManager::Get()), |
51 true, | 54 true, |
52 ash::A11Y_NOTIFICATION_NONE); | 55 ash::A11Y_NOTIFICATION_NONE); |
53 WaitForExtension(extension_misc::kChromeVoxExtensionId, load_cb); | 56 WaitForExtension(extension_misc::kChromeVoxExtensionId, load_cb); |
54 */}); | 57 */}); |
58 }, | |
59 | |
60 /** | |
61 * Run a test with the specified HTML snippet loaded. | |
62 * @param {function() : void} doc Snippet wrapped inside of a function. | |
63 * @param {function()} callback Called once the document is ready. | |
64 */ | |
65 runWithDocument: function(doc, callback) { | |
dmazzoni
2014/09/26 06:08:52
Nice!
| |
66 var docString = TestUtils.extractHtmlFromCommentEncodedString(doc); | |
67 var url = 'data:text/html,<!doctype html><html><body>' + | |
68 docString + | |
69 '<!-- chromevox_next_test -->' + | |
70 '</body></html>'; | |
71 var createParams = { | |
72 active: true, | |
73 url: url | |
74 }; | |
75 chrome.tabs.create(createParams, function(tab) { | |
76 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo) { | |
77 if (tabId == tab.id && changeInfo.status == 'complete') { | |
78 callback(); | |
79 } | |
80 }); | |
81 }); | |
55 } | 82 } |
56 }; | 83 }; |
57 | 84 |
58 /** | 85 /** |
59 * Similar to |TEST_F|. Generates a test for the given |testFixture|, | 86 * Similar to |TEST_F|. Generates a test for the given |testFixture|, |
60 * |testName|, and |testFunction|. | 87 * |testName|, and |testFunction|. |
61 * Used this variant when an |isAsync| fixture wants to temporarily mix in an | 88 * Used this variant when an |isAsync| fixture wants to temporarily mix in an |
62 * sync test. | 89 * sync test. |
63 * @param {string} testFixture Fixture name. | 90 * @param {string} testFixture Fixture name. |
64 * @param {string} testName Test name. | 91 * @param {string} testName Test name. |
65 * @param {function} testFunction The test impl. | 92 * @param {function} testFunction The test impl. |
66 */ | 93 */ |
67 function SYNC_TEST_F(testFixture, testName, testFunction) { | 94 function SYNC_TEST_F(testFixture, testName, testFunction) { |
68 var wrappedTestFunction = function() { | 95 var wrappedTestFunction = function() { |
69 testFunction.call(this); | 96 testFunction.call(this); |
70 testDone([true, '']); | 97 testDone([true, '']); |
71 }; | 98 }; |
72 TEST_F(testFixture, testName, wrappedTestFunction); | 99 TEST_F(testFixture, testName, wrappedTestFunction); |
73 } | 100 } |
OLD | NEW |