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

Side by Side Diff: chrome/browser/extensions/api/automation/automation_apitest.cc

Issue 940753002: accessibility: Simpler AXTree root accessor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix win Created 5 years, 10 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 | « no previous file | content/browser/accessibility/accessibility_ipc_error_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "base/files/file_path.h" 5 #include "base/files/file_path.h"
6 #include "base/path_service.h" 6 #include "base/path_service.h"
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "chrome/browser/extensions/api/automation_internal/automation_util.h" 8 #include "chrome/browser/extensions/api/automation_internal/automation_util.h"
9 #include "chrome/browser/extensions/chrome_extension_function.h" 9 #include "chrome/browser/extensions/chrome_extension_function.h"
10 #include "chrome/browser/extensions/extension_apitest.h" 10 #include "chrome/browser/extensions/extension_apitest.h"
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 tree0_version(0), 230 tree0_version(0),
231 tree1_version(0) { 231 tree1_version(0) {
232 } 232 }
233 233
234 // Serializes tree and sends it as an accessibility event to the extension. 234 // Serializes tree and sends it as an accessibility event to the extension.
235 void SendDataForTree(const ui::AXTree* tree, 235 void SendDataForTree(const ui::AXTree* tree,
236 TreeSerializer* serializer, 236 TreeSerializer* serializer,
237 int routing_id, 237 int routing_id,
238 BrowserContext* browser_context) { 238 BrowserContext* browser_context) {
239 ui::AXTreeUpdate update; 239 ui::AXTreeUpdate update;
240 serializer->SerializeChanges(tree->GetRoot(), &update); 240 serializer->SerializeChanges(tree->root(), &update);
241 SendUpdate(update, 241 SendUpdate(update,
242 ui::AX_EVENT_LAYOUT_COMPLETE, 242 ui::AX_EVENT_LAYOUT_COMPLETE,
243 tree->GetRoot()->id(), 243 tree->root()->id(),
244 routing_id, 244 routing_id,
245 browser_context); 245 browser_context);
246 } 246 }
247 247
248 // Sends the given AXTreeUpdate to the extension as an accessibility event. 248 // Sends the given AXTreeUpdate to the extension as an accessibility event.
249 void SendUpdate(ui::AXTreeUpdate update, 249 void SendUpdate(ui::AXTreeUpdate update,
250 ui::AXEvent event, 250 ui::AXEvent event,
251 int node_id, 251 int node_id,
252 int routing_id, 252 int routing_id,
253 BrowserContext* browser_context) { 253 BrowserContext* browser_context) {
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 content::BrowserContext* browser_context) { 391 content::BrowserContext* browser_context) {
392 source_serializer->ChangeTreeSourceForTesting(target_tree_source); 392 source_serializer->ChangeTreeSourceForTesting(target_tree_source);
393 for (int node_delta = 0; node_delta < state.tree_size; ++node_delta) { 393 for (int node_delta = 0; node_delta < state.tree_size; ++node_delta) {
394 int id = 1 + (state.starting_node + node_delta) % state.tree_size; 394 int id = 1 + (state.starting_node + node_delta) % state.tree_size;
395 ui::AXTreeUpdate update; 395 ui::AXTreeUpdate update;
396 source_serializer->SerializeChanges(target_tree->GetFromId(id), &update); 396 source_serializer->SerializeChanges(target_tree->GetFromId(id), &update);
397 bool is_last_update = node_delta == state.tree_size - 1; 397 bool is_last_update = node_delta == state.tree_size - 1;
398 ui::AXEvent event = 398 ui::AXEvent event =
399 is_last_update ? AX_EVENT_ASSERT_EQUAL : AX_EVENT_IGNORE; 399 is_last_update ? AX_EVENT_ASSERT_EQUAL : AX_EVENT_IGNORE;
400 state.SendUpdate( 400 state.SendUpdate(
401 update, event, target_tree->GetRoot()->id(), kTab0Rid, browser_context); 401 update, event, target_tree->root()->id(), kTab0Rid, browser_context);
402 } 402 }
403 } 403 }
404 404
405 // Helper method to send a no-op tree update to tab 0 with the given event. 405 // Helper method to send a no-op tree update to tab 0 with the given event.
406 void SendEvent(ui::AXEvent event, content::BrowserContext* browser_context) { 406 void SendEvent(ui::AXEvent event, content::BrowserContext* browser_context) {
407 ui::AXTreeUpdate update; 407 ui::AXTreeUpdate update;
408 ui::AXNode* root = state.tree0->GetRoot(); 408 ui::AXNode* root = state.tree0->root();
409 state.serializer0->SerializeChanges(root, &update); 409 state.serializer0->SerializeChanges(root, &update);
410 state.SendUpdate(update, event, root->id(), kTab0Rid, browser_context); 410 state.SendUpdate(update, event, root->id(), kTab0Rid, browser_context);
411 } 411 }
412 412
413 // Override for chrome.automationInternal.performAction 413 // Override for chrome.automationInternal.performAction
414 // This is used as a synchronization mechanism; the general flow is: 414 // This is used as a synchronization mechanism; the general flow is:
415 // 1. The extension requests tree0 and tree1 (on tab 0 and tab 1 respectively) 415 // 1. The extension requests tree0 and tree1 (on tab 0 and tab 1 respectively)
416 // 2. FakeAutomationInternalEnableTabFunction sends down the trees 416 // 2. FakeAutomationInternalEnableTabFunction sends down the trees
417 // 3. When the callback for getTree(0) fires, the extension calls doDefault() on 417 // 3. When the callback for getTree(0) fires, the extension calls doDefault() on
418 // the root node of tree0, which calls into this class's Run() method. 418 // the root node of tree0, which calls into this class's Run() method.
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 "automationInternal.enableTab", 512 "automationInternal.enableTab",
513 FakeAutomationInternalEnableTabFunctionFactory)); 513 FakeAutomationInternalEnableTabFunctionFactory));
514 ASSERT_TRUE(extensions::ExtensionFunctionDispatcher::OverrideFunction( 514 ASSERT_TRUE(extensions::ExtensionFunctionDispatcher::OverrideFunction(
515 "automationInternal.performAction", 515 "automationInternal.performAction",
516 FakeAutomationInternalPerformActionFunctionFactory)); 516 FakeAutomationInternalPerformActionFunctionFactory));
517 ASSERT_TRUE(RunExtensionSubtest("automation/tests/generated", 517 ASSERT_TRUE(RunExtensionSubtest("automation/tests/generated",
518 "generated_trees.html")) << message_; 518 "generated_trees.html")) << message_;
519 } 519 }
520 520
521 } // namespace extensions 521 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | content/browser/accessibility/accessibility_ipc_error_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698