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([ | 5 GEN_INCLUDE([ |
6 'chrome/browser/resources/chromeos/chromevox/testing/common.js']); | 6 'chrome/browser/resources/chromeos/chromevox/testing/common.js']); |
7 | 7 |
8 /** | 8 /** |
9 * Base test fixture for ChromeVox end to end tests. | 9 * Base test fixture for ChromeVox end to end tests. |
10 * | 10 * |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 base::Closure load_cb = | 51 base::Closure load_cb = |
52 base::Bind(&chromeos::AccessibilityManager::EnableSpokenFeedback, | 52 base::Bind(&chromeos::AccessibilityManager::EnableSpokenFeedback, |
53 base::Unretained(chromeos::AccessibilityManager::Get()), | 53 base::Unretained(chromeos::AccessibilityManager::Get()), |
54 true, | 54 true, |
55 ui::A11Y_NOTIFICATION_NONE); | 55 ui::A11Y_NOTIFICATION_NONE); |
56 WaitForExtension(extension_misc::kChromeVoxExtensionId, load_cb); | 56 WaitForExtension(extension_misc::kChromeVoxExtensionId, load_cb); |
57 */}); | 57 */}); |
58 }, | 58 }, |
59 | 59 |
60 /** | 60 /** |
61 * Run a test with the specified HTML snippet loaded. | 61 * Launch a new tab, wait until tab status complete, then run callback. |
62 * @param {function() : void} doc Snippet wrapped inside of a function. | 62 * @param {function() : void} doc Snippet wrapped inside of a function. |
63 * @param {function()} callback Called once the document is ready. | 63 * @param {function()} callback Called once the document is ready. |
64 */ | 64 */ |
65 runWithDocument: function(doc, callback) { | 65 runWithLoadedTab: function(doc, callback) { |
| 66 this.launchNewTabWithDoc(doc, function(tab) { |
| 67 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo) { |
| 68 if (tabId == tab.id && changeInfo.status == 'complete') { |
| 69 callback(tabId); |
| 70 } |
| 71 }); |
| 72 }); |
| 73 }, |
| 74 |
| 75 /** |
| 76 * Launches the given document in a new tab. |
| 77 * @param {function() : void} doc Snippet wrapped inside of a function. |
| 78 * @param {function()} opt_callback Called once the document is created. |
| 79 */ |
| 80 runWithTab: function(doc, opt_callback) { |
66 var docString = TestUtils.extractHtmlFromCommentEncodedString(doc); | 81 var docString = TestUtils.extractHtmlFromCommentEncodedString(doc); |
67 var url = 'data:text/html,<!doctype html>' + | 82 var url = 'data:text/html,<!doctype html>' + |
68 docString + | 83 docString + |
69 '<!-- chromevox_next_test -->'; | 84 '<!-- chromevox_next_test -->'; |
70 var createParams = { | 85 var createParams = { |
71 active: true, | 86 active: true, |
72 url: url | 87 url: url |
73 }; | 88 }; |
74 chrome.tabs.create(createParams, function(tab) { | 89 chrome.tabs.create(createParams, opt_callback); |
75 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo) { | |
76 if (tabId == tab.id && changeInfo.status == 'complete') { | |
77 callback(tabId); | |
78 } | |
79 }); | |
80 }); | |
81 }, | 90 }, |
82 | 91 |
83 /** | 92 /** |
84 * Send a key to the page. | 93 * Send a key to the page. |
85 * @param {number} tabId Of the page. | 94 * @param {number} tabId Of the page. |
86 * @param {string} key Name of the key (e.g. Down). | 95 * @param {string} key Name of the key (e.g. Down). |
87 * @param {string} elementQueryString | 96 * @param {string} elementQueryString |
88 */ | 97 */ |
89 sendKeyToElement: function(tabId, key, elementQueryString) { | 98 sendKeyToElement: function(tabId, key, elementQueryString) { |
90 var code = TestUtils.extractHtmlFromCommentEncodedString(function() {/*! | 99 var code = TestUtils.extractHtmlFromCommentEncodedString(function() {/*! |
(...skipping 18 matching lines...) Expand all Loading... |
109 * @param {string} testName Test name. | 118 * @param {string} testName Test name. |
110 * @param {function} testFunction The test impl. | 119 * @param {function} testFunction The test impl. |
111 */ | 120 */ |
112 function SYNC_TEST_F(testFixture, testName, testFunction) { | 121 function SYNC_TEST_F(testFixture, testName, testFunction) { |
113 var wrappedTestFunction = function() { | 122 var wrappedTestFunction = function() { |
114 testFunction.call(this); | 123 testFunction.call(this); |
115 testDone([true, '']); | 124 testDone([true, '']); |
116 }; | 125 }; |
117 TEST_F(testFixture, testName, wrappedTestFunction); | 126 TEST_F(testFixture, testName, wrappedTestFunction); |
118 } | 127 } |
OLD | NEW |