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) { |
| 66 var docString = TestUtils.extractHtmlFromCommentEncodedString(doc); |
| 67 var url = 'data:text/html,<!doctype html>' + |
| 68 docString + |
| 69 '<!-- chromevox_next_test -->'; |
| 70 var createParams = { |
| 71 active: true, |
| 72 url: url |
| 73 }; |
| 74 chrome.tabs.create(createParams, function(tab) { |
| 75 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo) { |
| 76 if (tabId == tab.id && changeInfo.status == 'complete') { |
| 77 callback(); |
| 78 } |
| 79 }); |
| 80 }); |
55 } | 81 } |
56 }; | 82 }; |
57 | 83 |
58 /** | 84 /** |
59 * Similar to |TEST_F|. Generates a test for the given |testFixture|, | 85 * Similar to |TEST_F|. Generates a test for the given |testFixture|, |
60 * |testName|, and |testFunction|. | 86 * |testName|, and |testFunction|. |
61 * Used this variant when an |isAsync| fixture wants to temporarily mix in an | 87 * Used this variant when an |isAsync| fixture wants to temporarily mix in an |
62 * sync test. | 88 * sync test. |
63 * @param {string} testFixture Fixture name. | 89 * @param {string} testFixture Fixture name. |
64 * @param {string} testName Test name. | 90 * @param {string} testName Test name. |
65 * @param {function} testFunction The test impl. | 91 * @param {function} testFunction The test impl. |
66 */ | 92 */ |
67 function SYNC_TEST_F(testFixture, testName, testFunction) { | 93 function SYNC_TEST_F(testFixture, testName, testFunction) { |
68 var wrappedTestFunction = function() { | 94 var wrappedTestFunction = function() { |
69 testFunction.call(this); | 95 testFunction.call(this); |
70 testDone([true, '']); | 96 testDone([true, '']); |
71 }; | 97 }; |
72 TEST_F(testFixture, testName, wrappedTestFunction); | 98 TEST_F(testFixture, testName, wrappedTestFunction); |
73 } | 99 } |
OLD | NEW |