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

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

Issue 1155183006: Reimplement automation API on top of C++-backed AXTree. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@automation_faster_2
Patch Set: Rebase, delete some code that shouldn't have been commented out Created 5 years, 6 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
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/accessibility/ax_tree_id_registry.h"
9 #include "chrome/browser/extensions/api/automation_internal/automation_event_rou ter.h"
9 #include "chrome/browser/extensions/chrome_extension_function.h" 10 #include "chrome/browser/extensions/chrome_extension_function.h"
10 #include "chrome/browser/extensions/extension_apitest.h" 11 #include "chrome/browser/extensions/extension_apitest.h"
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" 12 #include "chrome/browser/ui/tabs/tab_strip_model.h"
12 #include "chrome/common/chrome_paths.h" 13 #include "chrome/common/chrome_paths.h"
13 #include "chrome/common/chrome_switches.h" 14 #include "chrome/common/chrome_switches.h"
14 #include "chrome/common/extensions/api/automation_internal.h" 15 #include "chrome/common/extensions/api/automation_internal.h"
16 #include "chrome/common/extensions/chrome_extension_messages.h"
15 #include "chrome/test/base/ui_test_utils.h" 17 #include "chrome/test/base/ui_test_utils.h"
16 #include "content/public/browser/ax_event_notification_details.h" 18 #include "content/public/browser/ax_event_notification_details.h"
17 #include "content/public/browser/render_widget_host.h" 19 #include "content/public/browser/render_widget_host.h"
18 #include "content/public/browser/render_widget_host_view.h" 20 #include "content/public/browser/render_widget_host_view.h"
19 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
20 #include "extensions/test/extension_test_message_listener.h" 22 #include "extensions/test/extension_test_message_listener.h"
21 #include "net/dns/mock_host_resolver.h" 23 #include "net/dns/mock_host_resolver.h"
22 #include "net/test/embedded_test_server/embedded_test_server.h" 24 #include "net/test/embedded_test_server/embedded_test_server.h"
23 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
24 #include "ui/accessibility/ax_node.h" 26 #include "ui/accessibility/ax_node.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 ASSERT_FALSE(tab->IsFullAccessibilityModeForTesting()); 91 ASSERT_FALSE(tab->IsFullAccessibilityModeForTesting());
90 ASSERT_TRUE(tab->IsTreeOnlyAccessibilityModeForTesting()); 92 ASSERT_TRUE(tab->IsTreeOnlyAccessibilityModeForTesting());
91 } 93 }
92 94
93 IN_PROC_BROWSER_TEST_F(AutomationApiTest, SanityCheck) { 95 IN_PROC_BROWSER_TEST_F(AutomationApiTest, SanityCheck) {
94 StartEmbeddedTestServer(); 96 StartEmbeddedTestServer();
95 ASSERT_TRUE(RunExtensionSubtest("automation/tests/tabs", "sanity_check.html")) 97 ASSERT_TRUE(RunExtensionSubtest("automation/tests/tabs", "sanity_check.html"))
96 << message_; 98 << message_;
97 } 99 }
98 100
99 IN_PROC_BROWSER_TEST_F(AutomationApiTest, Unit) {
100 ASSERT_TRUE(RunExtensionSubtest("automation/tests/unit", "unit.html"))
101 << message_;
102 }
103
104 IN_PROC_BROWSER_TEST_F(AutomationApiTest, GetTreeByTabId) { 101 IN_PROC_BROWSER_TEST_F(AutomationApiTest, GetTreeByTabId) {
105 StartEmbeddedTestServer(); 102 StartEmbeddedTestServer();
106 ASSERT_TRUE(RunExtensionSubtest("automation/tests/tabs", "tab_id.html")) 103 ASSERT_TRUE(RunExtensionSubtest("automation/tests/tabs", "tab_id.html"))
107 << message_; 104 << message_;
108 } 105 }
109 106
110 IN_PROC_BROWSER_TEST_F(AutomationApiTest, Events) { 107 IN_PROC_BROWSER_TEST_F(AutomationApiTest, Events) {
111 StartEmbeddedTestServer(); 108 StartEmbeddedTestServer();
112 ASSERT_TRUE(RunExtensionSubtest("automation/tests/tabs", "events.html")) 109 ASSERT_TRUE(RunExtensionSubtest("automation/tests/tabs", "events.html"))
113 << message_; 110 << message_;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 RunExtensionSubtest("automation/tests/tabs", "queryselector.html")) 190 RunExtensionSubtest("automation/tests/tabs", "queryselector.html"))
194 << message_; 191 << message_;
195 } 192 }
196 193
197 IN_PROC_BROWSER_TEST_F(AutomationApiTest, Find) { 194 IN_PROC_BROWSER_TEST_F(AutomationApiTest, Find) {
198 StartEmbeddedTestServer(); 195 StartEmbeddedTestServer();
199 ASSERT_TRUE(RunExtensionSubtest("automation/tests/tabs", "find.html")) 196 ASSERT_TRUE(RunExtensionSubtest("automation/tests/tabs", "find.html"))
200 << message_; 197 << message_;
201 } 198 }
202 199
203 // Flaky. http://crbug.com/467921 200 IN_PROC_BROWSER_TEST_F(AutomationApiTest, Attributes) {
204 IN_PROC_BROWSER_TEST_F(AutomationApiTest, DISABLED_Mixins) {
205 StartEmbeddedTestServer(); 201 StartEmbeddedTestServer();
206 ASSERT_TRUE(RunExtensionSubtest("automation/tests/tabs", "mixins.html")) 202 ASSERT_TRUE(RunExtensionSubtest("automation/tests/tabs", "attributes.html"))
207 << message_; 203 << message_;
208 } 204 }
209 205
210 IN_PROC_BROWSER_TEST_F(AutomationApiTest, TreeChange) { 206 IN_PROC_BROWSER_TEST_F(AutomationApiTest, TreeChange) {
211 StartEmbeddedTestServer(); 207 StartEmbeddedTestServer();
212 ASSERT_TRUE(RunExtensionSubtest("automation/tests/tabs", "tree_change.html")) 208 ASSERT_TRUE(RunExtensionSubtest("automation/tests/tabs", "tree_change.html"))
213 << message_; 209 << message_;
214 } 210 }
215 211
216 212
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 routing_id, 260 routing_id,
265 browser_context); 261 browser_context);
266 } 262 }
267 263
268 // Sends the given AXTreeUpdate to the extension as an accessibility event. 264 // Sends the given AXTreeUpdate to the extension as an accessibility event.
269 void SendUpdate(ui::AXTreeUpdate update, 265 void SendUpdate(ui::AXTreeUpdate update,
270 ui::AXEvent event, 266 ui::AXEvent event,
271 int node_id, 267 int node_id,
272 int routing_id, 268 int routing_id,
273 BrowserContext* browser_context) { 269 BrowserContext* browser_context) {
274 content::AXEventNotificationDetails detail(update.node_id_to_clear, 270 ExtensionMsg_AccessibilityEventParams params;
275 update.nodes, 271 params.tree_id = AXTreeIDRegistry::GetInstance()->GetOrCreateAXTreeID(
276 event, 272 kPid, routing_id);
277 node_id, 273 params.id = node_id;
278 kPid, 274 params.event_type = event;
279 routing_id); 275 params.update = update;
280 std::vector<content::AXEventNotificationDetails> details; 276 AutomationEventRouter* router = AutomationEventRouter::GetInstance();
281 details.push_back(detail); 277 router->DispatchAccessibilityEvent(params);
282 automation_util::DispatchAccessibilityEventsToAutomation(
283 details, browser_context, gfx::Vector2d());
284 } 278 }
285 279
286 // Notify the extension bindings to destroy the tree for the given tab 280 // Notify the extension bindings to destroy the tree for the given tab
287 // (identified by routing_id) 281 // (identified by routing_id)
288 void SendTreeDestroyedEvent(int routing_id, BrowserContext* browser_context) { 282 void SendTreeDestroyedEvent(int routing_id, BrowserContext* browser_context) {
289 automation_util::DispatchTreeDestroyedEventToAutomation( 283 int tree_id = AXTreeIDRegistry::GetInstance()->GetOrCreateAXTreeID(
David Tseng 2015/06/10 15:56:31 Is this code (and the generated tree test) obsolet
dmazzoni 2015/06/11 19:09:11 You're right, deleted.
290 kPid, routing_id, browser_context); 284 kPid, routing_id);
285 AXTreeIDRegistry::GetInstance()->RemoveAXTreeID(tree_id);
286
287 AutomationEventRouter* router = AutomationEventRouter::GetInstance();
288 router->DispatchTreeDestroyedEvent(tree_id, browser_context);
291 } 289 }
292 290
293 // Reset tree0 to a new generated tree based on tree0_version, reset 291 // Reset tree0 to a new generated tree based on tree0_version, reset
294 // tree0_source accordingly. 292 // tree0_source accordingly.
295 void ResetTree0() { 293 void ResetTree0() {
296 tree0.reset(new ui::AXSerializableTree); 294 tree0.reset(new ui::AXSerializableTree);
297 tree0_source.reset(tree0->CreateTreeSource()); 295 tree0_source.reset(tree0->CreateTreeSource());
298 generator.BuildUniqueTree(tree0_version, tree0.get()); 296 generator.BuildUniqueTree(tree0_version, tree0.get());
299 if (!serializer0.get()) 297 if (!serializer0.get())
300 serializer0.reset(new TreeSerializer(tree0_source.get())); 298 serializer0.reset(new TreeSerializer(tree0_source.get()));
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 "automationInternal.enableTab", 530 "automationInternal.enableTab",
533 FakeAutomationInternalEnableTabFunctionFactory)); 531 FakeAutomationInternalEnableTabFunctionFactory));
534 ASSERT_TRUE(extensions::ExtensionFunctionDispatcher::OverrideFunction( 532 ASSERT_TRUE(extensions::ExtensionFunctionDispatcher::OverrideFunction(
535 "automationInternal.performAction", 533 "automationInternal.performAction",
536 FakeAutomationInternalPerformActionFunctionFactory)); 534 FakeAutomationInternalPerformActionFunctionFactory));
537 ASSERT_TRUE(RunExtensionSubtest("automation/tests/generated", 535 ASSERT_TRUE(RunExtensionSubtest("automation/tests/generated",
538 "generated_trees.html")) << message_; 536 "generated_trees.html")) << message_;
539 } 537 }
540 538
541 } // namespace extensions 539 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698