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

Side by Side Diff: trunk/src/content/renderer/accessibility/renderer_accessibility_browsertest.cc

Issue 177713006: Revert 251563 "Move browser initiated navigation from RenderView..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/strings/utf_string_conversions.h" 5 #include "base/strings/utf_string_conversions.h"
6 #include "content/common/frame_messages.h" 6 #include "content/common/view_messages.h"
7 #include "content/public/test/render_view_test.h" 7 #include "content/public/test/render_view_test.h"
8 #include "content/renderer/accessibility/renderer_accessibility_complete.h" 8 #include "content/renderer/accessibility/renderer_accessibility_complete.h"
9 #include "content/renderer/render_view_impl.h" 9 #include "content/renderer/render_view_impl.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "third_party/WebKit/public/platform/WebSize.h" 11 #include "third_party/WebKit/public/platform/WebSize.h"
12 #include "third_party/WebKit/public/web/WebAXObject.h" 12 #include "third_party/WebKit/public/web/WebAXObject.h"
13 #include "third_party/WebKit/public/web/WebDocument.h" 13 #include "third_party/WebKit/public/web/WebDocument.h"
14 #include "third_party/WebKit/public/web/WebView.h" 14 #include "third_party/WebKit/public/web/WebView.h"
15 #include "ui/accessibility/ax_node_data.h" 15 #include "ui/accessibility/ax_node_data.h"
16 16
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 }; 55 };
56 56
57 class RendererAccessibilityTest : public RenderViewTest { 57 class RendererAccessibilityTest : public RenderViewTest {
58 public: 58 public:
59 RendererAccessibilityTest() {} 59 RendererAccessibilityTest() {}
60 60
61 RenderViewImpl* view() { 61 RenderViewImpl* view() {
62 return static_cast<RenderViewImpl*>(view_); 62 return static_cast<RenderViewImpl*>(view_);
63 } 63 }
64 64
65 RenderFrameImpl* frame() {
66 return static_cast<RenderFrameImpl*>(view()->GetMainRenderFrame());
67 }
68
69 virtual void SetUp() { 65 virtual void SetUp() {
70 RenderViewTest::SetUp(); 66 RenderViewTest::SetUp();
71 sink_ = &render_thread_->sink(); 67 sink_ = &render_thread_->sink();
72 } 68 }
73 69
74 void SetMode(unsigned int mode) { 70 void SetMode(unsigned int mode) {
75 view()->OnSetAccessibilityMode(mode); 71 view()->OnSetAccessibilityMode(mode);
76 } 72 }
77 73
78 void GetLastAccEvent( 74 void GetLastAccEvent(
(...skipping 10 matching lines...) Expand all
89 int CountAccessibilityNodesSentToBrowser() { 85 int CountAccessibilityNodesSentToBrowser() {
90 AccessibilityHostMsg_EventParams event; 86 AccessibilityHostMsg_EventParams event;
91 GetLastAccEvent(&event); 87 GetLastAccEvent(&event);
92 return event.nodes.size(); 88 return event.nodes.size();
93 } 89 }
94 90
95 protected: 91 protected:
96 IPC::TestSink* sink_; 92 IPC::TestSink* sink_;
97 93
98 DISALLOW_COPY_AND_ASSIGN(RendererAccessibilityTest); 94 DISALLOW_COPY_AND_ASSIGN(RendererAccessibilityTest);
99
100 }; 95 };
101 96
102 TEST_F(RendererAccessibilityTest, EditableTextModeFocusEvents) { 97 TEST_F(RendererAccessibilityTest, EditableTextModeFocusEvents) {
103 // This is not a test of true web accessibility, it's a test of 98 // This is not a test of true web accessibility, it's a test of
104 // a mode used on Windows 8 in Metro mode where an extremely simplified 99 // a mode used on Windows 8 in Metro mode where an extremely simplified
105 // accessibility tree containing only the current focused node is 100 // accessibility tree containing only the current focused node is
106 // generated. 101 // generated.
107 SetMode(AccessibilityModeEditableTextOnly); 102 SetMode(AccessibilityModeEditableTextOnly);
108 103
109 // Set a minimum size and give focus so simulated events work. 104 // Set a minimum size and give focus so simulated events work.
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 view()->OnSwapOut(); 347 view()->OnSwapOut();
353 accessibility->SendPendingAccessibilityEvents(); 348 accessibility->SendPendingAccessibilityEvents();
354 EXPECT_FALSE(sink_->GetUniqueMessageMatching( 349 EXPECT_FALSE(sink_->GetUniqueMessageMatching(
355 AccessibilityHostMsg_Events::ID)); 350 AccessibilityHostMsg_Events::ID));
356 351
357 // Navigate, so we're not swapped out anymore. Now we should 352 // Navigate, so we're not swapped out anymore. Now we should
358 // send accessibility events again. Note that the 353 // send accessibility events again. Note that the
359 // message that was queued up before will be quickly discarded 354 // message that was queued up before will be quickly discarded
360 // because the element it was referring to no longer exists, 355 // because the element it was referring to no longer exists,
361 // so the event here is from loading this new page. 356 // so the event here is from loading this new page.
362 FrameMsg_Navigate_Params nav_params; 357 ViewMsg_Navigate_Params nav_params;
363 nav_params.url = GURL("data:text/html,<p>Hello, again.</p>"); 358 nav_params.url = GURL("data:text/html,<p>Hello, again.</p>");
364 nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 359 nav_params.navigation_type = ViewMsg_Navigate_Type::NORMAL;
365 nav_params.transition = PAGE_TRANSITION_TYPED; 360 nav_params.transition = PAGE_TRANSITION_TYPED;
366 nav_params.current_history_list_length = 1; 361 nav_params.current_history_list_length = 1;
367 nav_params.current_history_list_offset = 0; 362 nav_params.current_history_list_offset = 0;
368 nav_params.pending_history_list_offset = 1; 363 nav_params.pending_history_list_offset = 1;
369 nav_params.page_id = -1; 364 nav_params.page_id = -1;
370 frame()->OnNavigate(nav_params); 365 view()->OnNavigate(nav_params);
371 accessibility->SendPendingAccessibilityEvents(); 366 accessibility->SendPendingAccessibilityEvents();
372 EXPECT_TRUE(sink_->GetUniqueMessageMatching( 367 EXPECT_TRUE(sink_->GetUniqueMessageMatching(
373 AccessibilityHostMsg_Events::ID)); 368 AccessibilityHostMsg_Events::ID));
374 } 369 }
375 370
376 TEST_F(RendererAccessibilityTest, HideAccessibilityObject) { 371 TEST_F(RendererAccessibilityTest, HideAccessibilityObject) {
377 // Test RendererAccessibilityComplete and make sure it sends the 372 // Test RendererAccessibilityComplete and make sure it sends the
378 // proper event to the browser when an object in the tree 373 // proper event to the browser when an object in the tree
379 // is hidden, but its children are not. 374 // is hidden, but its children are not.
380 std::string html = 375 std::string html =
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 GetLastAccEvent(&event); 532 GetLastAccEvent(&event);
538 ASSERT_EQ(5U, event.nodes.size()); 533 ASSERT_EQ(5U, event.nodes.size());
539 534
540 EXPECT_EQ(body.axID(), event.nodes[0].id); 535 EXPECT_EQ(body.axID(), event.nodes[0].id);
541 EXPECT_EQ(text_1.axID(), event.nodes[1].id); 536 EXPECT_EQ(text_1.axID(), event.nodes[1].id);
542 // The third event is to update text_2, but its id changes 537 // The third event is to update text_2, but its id changes
543 // so we don't have a test expectation for it. 538 // so we don't have a test expectation for it.
544 } 539 }
545 540
546 } // namespace content 541 } // namespace content
OLDNEW
« no previous file with comments | « trunk/src/content/public/test/render_view_test.cc ('k') | trunk/src/content/renderer/devtools/devtools_agent.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698