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

Side by Side Diff: content/renderer/render_view_browsertest.cc

Issue 11232014: Move a bunch of code in content\renderer to the content namespace. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix mac Created 8 years, 2 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/basictypes.h" 5 #include "base/basictypes.h"
6 6
7 #include "base/shared_memory.h" 7 #include "base/shared_memory.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "content/common/intents_messages.h" 10 #include "content/common/intents_messages.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "ui/base/keycodes/keyboard_code_conversion.h" 48 #include "ui/base/keycodes/keyboard_code_conversion.h"
49 #include "ui/base/x/x11_util.h" 49 #include "ui/base/x/x11_util.h"
50 #endif 50 #endif
51 51
52 using WebKit::WebFrame; 52 using WebKit::WebFrame;
53 using WebKit::WebInputEvent; 53 using WebKit::WebInputEvent;
54 using WebKit::WebMouseEvent; 54 using WebKit::WebMouseEvent;
55 using WebKit::WebString; 55 using WebKit::WebString;
56 using WebKit::WebTextDirection; 56 using WebKit::WebTextDirection;
57 using WebKit::WebURLError; 57 using WebKit::WebURLError;
58 using content::NativeWebKeyboardEvent; 58
59 namespace content {
59 60
60 namespace { 61 namespace {
61 #if defined(USE_AURA) && defined(USE_X11) 62 #if defined(USE_AURA) && defined(USE_X11)
62 // Converts MockKeyboard::Modifiers to ui::EventFlags. 63 // Converts MockKeyboard::Modifiers to ui::EventFlags.
63 int ConvertMockKeyboardModifier(MockKeyboard::Modifiers modifiers) { 64 int ConvertMockKeyboardModifier(MockKeyboard::Modifiers modifiers) {
64 static struct ModifierMap { 65 static struct ModifierMap {
65 MockKeyboard::Modifiers src; 66 MockKeyboard::Modifiers src;
66 int dst; 67 int dst;
67 } kModifierMap[] = { 68 } kModifierMap[] = {
68 { MockKeyboard::LEFT_SHIFT, ui::EF_SHIFT_DOWN }, 69 { MockKeyboard::LEFT_SHIFT, ui::EF_SHIFT_DOWN },
69 { MockKeyboard::RIGHT_SHIFT, ui::EF_SHIFT_DOWN }, 70 { MockKeyboard::RIGHT_SHIFT, ui::EF_SHIFT_DOWN },
70 { MockKeyboard::LEFT_CONTROL, ui::EF_CONTROL_DOWN }, 71 { MockKeyboard::LEFT_CONTROL, ui::EF_CONTROL_DOWN },
71 { MockKeyboard::RIGHT_CONTROL, ui::EF_CONTROL_DOWN }, 72 { MockKeyboard::RIGHT_CONTROL, ui::EF_CONTROL_DOWN },
72 { MockKeyboard::LEFT_ALT, ui::EF_ALT_DOWN }, 73 { MockKeyboard::LEFT_ALT, ui::EF_ALT_DOWN },
73 { MockKeyboard::RIGHT_ALT, ui::EF_ALT_DOWN }, 74 { MockKeyboard::RIGHT_ALT, ui::EF_ALT_DOWN },
74 }; 75 };
75 int flags = 0; 76 int flags = 0;
76 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kModifierMap); ++i) { 77 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kModifierMap); ++i) {
77 if (kModifierMap[i].src & modifiers) { 78 if (kModifierMap[i].src & modifiers) {
78 flags |= kModifierMap[i].dst; 79 flags |= kModifierMap[i].dst;
79 } 80 }
80 } 81 }
81 return flags; 82 return flags;
82 } 83 }
83 #endif 84 #endif
84 85
85 class WebUITestWebUIControllerFactory : public content::WebUIControllerFactory { 86 class WebUITestWebUIControllerFactory : public WebUIControllerFactory {
86 public: 87 public:
87 virtual content::WebUIController* CreateWebUIControllerForURL( 88 virtual WebUIController* CreateWebUIControllerForURL(
88 content::WebUI* web_ui, const GURL& url) const OVERRIDE { 89 WebUI* web_ui, const GURL& url) const OVERRIDE {
89 return NULL; 90 return NULL;
90 } 91 }
91 virtual content::WebUI::TypeID GetWebUIType( 92 virtual WebUI::TypeID GetWebUIType(BrowserContext* browser_context,
92 content::BrowserContext* browser_context, 93 const GURL& url) const OVERRIDE {
93 const GURL& url) const OVERRIDE { 94 return WebUI::kNoWebUI;
94 return content::WebUI::kNoWebUI;
95 } 95 }
96 virtual bool UseWebUIForURL(content::BrowserContext* browser_context, 96 virtual bool UseWebUIForURL(BrowserContext* browser_context,
97 const GURL& url) const OVERRIDE { 97 const GURL& url) const OVERRIDE {
98 return content::GetContentClient()->HasWebUIScheme(url); 98 return GetContentClient()->HasWebUIScheme(url);
99 } 99 }
100 virtual bool UseWebUIBindingsForURL(content::BrowserContext* browser_context, 100 virtual bool UseWebUIBindingsForURL(BrowserContext* browser_context,
101 const GURL& url) const OVERRIDE { 101 const GURL& url) const OVERRIDE {
102 return content::GetContentClient()->HasWebUIScheme(url); 102 return GetContentClient()->HasWebUIScheme(url);
103 } 103 }
104 virtual bool IsURLAcceptableForWebUI( 104 virtual bool IsURLAcceptableForWebUI(
105 content::BrowserContext* browser_context, 105 BrowserContext* browser_context,
106 const GURL& url, 106 const GURL& url,
107 bool data_urls_allowed) const OVERRIDE { 107 bool data_urls_allowed) const OVERRIDE {
108 return false; 108 return false;
109 } 109 }
110 }; 110 };
111 111
112 class WebUITestClient : public content::ShellContentClient { 112 class WebUITestClient : public ShellContentClient {
113 public: 113 public:
114 WebUITestClient() { 114 WebUITestClient() {
115 } 115 }
116 116
117 virtual bool HasWebUIScheme(const GURL& url) const OVERRIDE { 117 virtual bool HasWebUIScheme(const GURL& url) const OVERRIDE {
118 return url.SchemeIs(chrome::kChromeUIScheme); 118 return url.SchemeIs(chrome::kChromeUIScheme);
119 } 119 }
120 }; 120 };
121 121
122 class WebUITestBrowserClient : public content::ShellContentBrowserClient { 122 class WebUITestBrowserClient : public ShellContentBrowserClient {
123 public: 123 public:
124 WebUITestBrowserClient() {} 124 WebUITestBrowserClient() {}
125 125
126 virtual content::WebUIControllerFactory* 126 virtual WebUIControllerFactory* GetWebUIControllerFactory() OVERRIDE {
127 GetWebUIControllerFactory() OVERRIDE {
128 return &factory_; 127 return &factory_;
129 } 128 }
130 129
131 private: 130 private:
132 WebUITestWebUIControllerFactory factory_; 131 WebUITestWebUIControllerFactory factory_;
133 }; 132 };
134 133
135 } 134 }
136 135
137 class RenderViewImplTest : public content::RenderViewTest { 136 class RenderViewImplTest : public RenderViewTest {
138 public: 137 public:
139 RenderViewImplTest() { 138 RenderViewImplTest() {
140 // Attach a pseudo keyboard device to this object. 139 // Attach a pseudo keyboard device to this object.
141 mock_keyboard_.reset(new MockKeyboard()); 140 mock_keyboard_.reset(new MockKeyboard());
142 } 141 }
143 142
144 RenderViewImpl* view() { 143 RenderViewImpl* view() {
145 return static_cast<RenderViewImpl*>(view_); 144 return static_cast<RenderViewImpl*>(view_);
146 } 145 }
147 146
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 EXPECT_TRUE(render_thread_->sink().GetUniqueMessageMatching( 296 EXPECT_TRUE(render_thread_->sink().GetUniqueMessageMatching(
298 ViewHostMsg_UpdateState::ID)); 297 ViewHostMsg_UpdateState::ID));
299 } 298 }
300 299
301 TEST_F(RenderViewImplTest, OnNavigationHttpPost) { 300 TEST_F(RenderViewImplTest, OnNavigationHttpPost) {
302 ViewMsg_Navigate_Params nav_params; 301 ViewMsg_Navigate_Params nav_params;
303 302
304 // An http url will trigger a resource load so cannot be used here. 303 // An http url will trigger a resource load so cannot be used here.
305 nav_params.url = GURL("data:text/html,<div>Page</div>"); 304 nav_params.url = GURL("data:text/html,<div>Page</div>");
306 nav_params.navigation_type = ViewMsg_Navigate_Type::NORMAL; 305 nav_params.navigation_type = ViewMsg_Navigate_Type::NORMAL;
307 nav_params.transition = content::PAGE_TRANSITION_TYPED; 306 nav_params.transition = PAGE_TRANSITION_TYPED;
308 nav_params.page_id = -1; 307 nav_params.page_id = -1;
309 nav_params.is_post = true; 308 nav_params.is_post = true;
310 309
311 // Set up post data. 310 // Set up post data.
312 const unsigned char* raw_data = reinterpret_cast<const unsigned char*>( 311 const unsigned char* raw_data = reinterpret_cast<const unsigned char*>(
313 "post \0\ndata"); 312 "post \0\ndata");
314 const unsigned int length = 11; 313 const unsigned int length = 11;
315 const std::vector<unsigned char> post_data(raw_data, raw_data + length); 314 const std::vector<unsigned char> post_data(raw_data, raw_data + length);
316 nav_params.browser_initiated_post_data = post_data; 315 nav_params.browser_initiated_post_data = post_data;
317 316
(...skipping 18 matching lines...) Expand all
336 bool successful = body.elementAt(0, element); 335 bool successful = body.elementAt(0, element);
337 EXPECT_TRUE(successful); 336 EXPECT_TRUE(successful);
338 EXPECT_EQ(WebKit::WebHTTPBody::Element::TypeData, element.type); 337 EXPECT_EQ(WebKit::WebHTTPBody::Element::TypeData, element.type);
339 EXPECT_EQ(length, element.data.size()); 338 EXPECT_EQ(length, element.data.size());
340 EXPECT_EQ(0, memcmp(raw_data, element.data.data(), length)); 339 EXPECT_EQ(0, memcmp(raw_data, element.data.data(), length));
341 } 340 }
342 341
343 TEST_F(RenderViewImplTest, DecideNavigationPolicy) { 342 TEST_F(RenderViewImplTest, DecideNavigationPolicy) {
344 WebUITestClient client; 343 WebUITestClient client;
345 WebUITestBrowserClient browser_client; 344 WebUITestBrowserClient browser_client;
346 content::ContentClient* old_client = content::GetContentClient(); 345 ContentClient* old_client = GetContentClient();
347 content::ContentBrowserClient* old_browser_client = 346 ContentBrowserClient* old_browser_client = GetContentClient()->browser();
348 content::GetContentClient()->browser();
349 347
350 content::SetContentClient(&client); 348 SetContentClient(&client);
351 content::GetContentClient()->set_browser_for_testing(&browser_client); 349 GetContentClient()->set_browser_for_testing(&browser_client);
352 client.set_renderer_for_testing(old_client->renderer()); 350 client.set_renderer_for_testing(old_client->renderer());
353 351
354 // Navigations to normal HTTP URLs can be handled locally. 352 // Navigations to normal HTTP URLs can be handled locally.
355 WebKit::WebURLRequest request(GURL("http://foo.com")); 353 WebKit::WebURLRequest request(GURL("http://foo.com"));
356 WebKit::WebNavigationPolicy policy = view()->decidePolicyForNavigation( 354 WebKit::WebNavigationPolicy policy = view()->decidePolicyForNavigation(
357 GetMainFrame(), 355 GetMainFrame(),
358 request, 356 request,
359 WebKit::WebNavigationTypeLinkClicked, 357 WebKit::WebNavigationTypeLinkClicked,
360 WebKit::WebNode(), 358 WebKit::WebNode(),
361 WebKit::WebNavigationPolicyCurrentTab, 359 WebKit::WebNavigationPolicyCurrentTab,
(...skipping 16 matching lines...) Expand all
378 WebKit::WebURLRequest popup_request(GURL("chrome://foo")); 376 WebKit::WebURLRequest popup_request(GURL("chrome://foo"));
379 policy = view()->decidePolicyForNavigation( 377 policy = view()->decidePolicyForNavigation(
380 GetMainFrame(), 378 GetMainFrame(),
381 popup_request, 379 popup_request,
382 WebKit::WebNavigationTypeLinkClicked, 380 WebKit::WebNavigationTypeLinkClicked,
383 WebKit::WebNode(), 381 WebKit::WebNode(),
384 WebKit::WebNavigationPolicyNewForegroundTab, 382 WebKit::WebNavigationPolicyNewForegroundTab,
385 false); 383 false);
386 EXPECT_EQ(WebKit::WebNavigationPolicyIgnore, policy); 384 EXPECT_EQ(WebKit::WebNavigationPolicyIgnore, policy);
387 385
388 content::GetContentClient()->set_browser_for_testing(old_browser_client); 386 GetContentClient()->set_browser_for_testing(old_browser_client);
389 content::SetContentClient(old_client); 387 SetContentClient(old_client);
390 } 388 }
391 389
392 TEST_F(RenderViewImplTest, DecideNavigationPolicyForWebUI) { 390 TEST_F(RenderViewImplTest, DecideNavigationPolicyForWebUI) {
393 // Enable bindings to simulate a WebUI view. 391 // Enable bindings to simulate a WebUI view.
394 view()->OnAllowBindings(content::BINDINGS_POLICY_WEB_UI); 392 view()->OnAllowBindings(BINDINGS_POLICY_WEB_UI);
395 393
396 // Navigations to normal HTTP URLs will be sent to browser process. 394 // Navigations to normal HTTP URLs will be sent to browser process.
397 WebKit::WebURLRequest request(GURL("http://foo.com")); 395 WebKit::WebURLRequest request(GURL("http://foo.com"));
398 WebKit::WebNavigationPolicy policy = view()->decidePolicyForNavigation( 396 WebKit::WebNavigationPolicy policy = view()->decidePolicyForNavigation(
399 GetMainFrame(), 397 GetMainFrame(),
400 request, 398 request,
401 WebKit::WebNavigationTypeLinkClicked, 399 WebKit::WebNavigationTypeLinkClicked,
402 WebKit::WebNode(), 400 WebKit::WebNode(),
403 WebKit::WebNavigationPolicyCurrentTab, 401 WebKit::WebNavigationPolicyCurrentTab,
404 false); 402 false);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 view()->OnSwapOut(params); 482 view()->OnSwapOut(params);
485 const IPC::Message* msg2 = render_thread_->sink().GetUniqueMessageMatching( 483 const IPC::Message* msg2 = render_thread_->sink().GetUniqueMessageMatching(
486 ViewHostMsg_SwapOut_ACK::ID); 484 ViewHostMsg_SwapOut_ACK::ID);
487 ASSERT_TRUE(msg2); 485 ASSERT_TRUE(msg2);
488 486
489 // If we navigate back to this RenderView, ensure we don't send a state 487 // If we navigate back to this RenderView, ensure we don't send a state
490 // update for the swapped out URL. (http://crbug.com/72235) 488 // update for the swapped out URL. (http://crbug.com/72235)
491 ViewMsg_Navigate_Params nav_params; 489 ViewMsg_Navigate_Params nav_params;
492 nav_params.url = GURL("data:text/html,<div>Page B</div>"); 490 nav_params.url = GURL("data:text/html,<div>Page B</div>");
493 nav_params.navigation_type = ViewMsg_Navigate_Type::NORMAL; 491 nav_params.navigation_type = ViewMsg_Navigate_Type::NORMAL;
494 nav_params.transition = content::PAGE_TRANSITION_TYPED; 492 nav_params.transition = PAGE_TRANSITION_TYPED;
495 nav_params.current_history_list_length = 1; 493 nav_params.current_history_list_length = 1;
496 nav_params.current_history_list_offset = 0; 494 nav_params.current_history_list_offset = 0;
497 nav_params.pending_history_list_offset = 1; 495 nav_params.pending_history_list_offset = 1;
498 nav_params.page_id = -1; 496 nav_params.page_id = -1;
499 view()->OnNavigate(nav_params); 497 view()->OnNavigate(nav_params);
500 ProcessPendingMessages(); 498 ProcessPendingMessages();
501 const IPC::Message* msg3 = render_thread_->sink().GetUniqueMessageMatching( 499 const IPC::Message* msg3 = render_thread_->sink().GetUniqueMessageMatching(
502 ViewHostMsg_UpdateState::ID); 500 ViewHostMsg_UpdateState::ID);
503 EXPECT_FALSE(msg3); 501 EXPECT_FALSE(msg3);
504 } 502 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 int page_id_C; 544 int page_id_C;
547 std::string state_C; 545 std::string state_C;
548 ViewHostMsg_UpdateState::Read(msg_C, &page_id_C, &state_C); 546 ViewHostMsg_UpdateState::Read(msg_C, &page_id_C, &state_C);
549 EXPECT_EQ(3, page_id_C); 547 EXPECT_EQ(3, page_id_C);
550 EXPECT_NE(state_B, state_C); 548 EXPECT_NE(state_B, state_C);
551 render_thread_->sink().ClearMessages(); 549 render_thread_->sink().ClearMessages();
552 550
553 // Go back to C and commit, preparing for our real test. 551 // Go back to C and commit, preparing for our real test.
554 ViewMsg_Navigate_Params params_C; 552 ViewMsg_Navigate_Params params_C;
555 params_C.navigation_type = ViewMsg_Navigate_Type::NORMAL; 553 params_C.navigation_type = ViewMsg_Navigate_Type::NORMAL;
556 params_C.transition = content::PAGE_TRANSITION_FORWARD_BACK; 554 params_C.transition = PAGE_TRANSITION_FORWARD_BACK;
557 params_C.current_history_list_length = 4; 555 params_C.current_history_list_length = 4;
558 params_C.current_history_list_offset = 3; 556 params_C.current_history_list_offset = 3;
559 params_C.pending_history_list_offset = 2; 557 params_C.pending_history_list_offset = 2;
560 params_C.page_id = 3; 558 params_C.page_id = 3;
561 params_C.state = state_C; 559 params_C.state = state_C;
562 view()->OnNavigate(params_C); 560 view()->OnNavigate(params_C);
563 ProcessPendingMessages(); 561 ProcessPendingMessages();
564 render_thread_->sink().ClearMessages(); 562 render_thread_->sink().ClearMessages();
565 563
566 // Go back twice quickly, such that page B does not have a chance to commit. 564 // Go back twice quickly, such that page B does not have a chance to commit.
567 // This leads to two changes to the back/forward list but only one change to 565 // This leads to two changes to the back/forward list but only one change to
568 // the RenderView's page ID. 566 // the RenderView's page ID.
569 567
570 // Back to page B (page_id 2), without committing. 568 // Back to page B (page_id 2), without committing.
571 ViewMsg_Navigate_Params params_B; 569 ViewMsg_Navigate_Params params_B;
572 params_B.navigation_type = ViewMsg_Navigate_Type::NORMAL; 570 params_B.navigation_type = ViewMsg_Navigate_Type::NORMAL;
573 params_B.transition = content::PAGE_TRANSITION_FORWARD_BACK; 571 params_B.transition = PAGE_TRANSITION_FORWARD_BACK;
574 params_B.current_history_list_length = 4; 572 params_B.current_history_list_length = 4;
575 params_B.current_history_list_offset = 2; 573 params_B.current_history_list_offset = 2;
576 params_B.pending_history_list_offset = 1; 574 params_B.pending_history_list_offset = 1;
577 params_B.page_id = 2; 575 params_B.page_id = 2;
578 params_B.state = state_B; 576 params_B.state = state_B;
579 view()->OnNavigate(params_B); 577 view()->OnNavigate(params_B);
580 578
581 // Back to page A (page_id 1) and commit. 579 // Back to page A (page_id 1) and commit.
582 ViewMsg_Navigate_Params params; 580 ViewMsg_Navigate_Params params;
583 params.navigation_type = ViewMsg_Navigate_Type::NORMAL; 581 params.navigation_type = ViewMsg_Navigate_Type::NORMAL;
584 params.transition = content::PAGE_TRANSITION_FORWARD_BACK; 582 params.transition = PAGE_TRANSITION_FORWARD_BACK;
585 params_B.current_history_list_length = 4; 583 params_B.current_history_list_length = 4;
586 params_B.current_history_list_offset = 2; 584 params_B.current_history_list_offset = 2;
587 params_B.pending_history_list_offset = 0; 585 params_B.pending_history_list_offset = 0;
588 params.page_id = 1; 586 params.page_id = 1;
589 params.state = state_A; 587 params.state = state_A;
590 view()->OnNavigate(params); 588 view()->OnNavigate(params);
591 ProcessPendingMessages(); 589 ProcessPendingMessages();
592 590
593 // Now ensure that the UpdateState message we receive is consistent 591 // Now ensure that the UpdateState message we receive is consistent
594 // and represents page C in both page_id and state. 592 // and represents page C in both page_id and state.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 ASSERT_TRUE(msg_A); 624 ASSERT_TRUE(msg_A);
627 int page_id_A; 625 int page_id_A;
628 std::string state_A; 626 std::string state_A;
629 ViewHostMsg_UpdateState::Read(msg_A, &page_id_A, &state_A); 627 ViewHostMsg_UpdateState::Read(msg_A, &page_id_A, &state_A);
630 EXPECT_EQ(1, page_id_A); 628 EXPECT_EQ(1, page_id_A);
631 render_thread_->sink().ClearMessages(); 629 render_thread_->sink().ClearMessages();
632 630
633 // Back to page A (page_id 1) and commit. 631 // Back to page A (page_id 1) and commit.
634 ViewMsg_Navigate_Params params_A; 632 ViewMsg_Navigate_Params params_A;
635 params_A.navigation_type = ViewMsg_Navigate_Type::NORMAL; 633 params_A.navigation_type = ViewMsg_Navigate_Type::NORMAL;
636 params_A.transition = content::PAGE_TRANSITION_FORWARD_BACK; 634 params_A.transition = PAGE_TRANSITION_FORWARD_BACK;
637 params_A.current_history_list_length = 2; 635 params_A.current_history_list_length = 2;
638 params_A.current_history_list_offset = 1; 636 params_A.current_history_list_offset = 1;
639 params_A.pending_history_list_offset = 0; 637 params_A.pending_history_list_offset = 0;
640 params_A.page_id = 1; 638 params_A.page_id = 1;
641 params_A.state = state_A; 639 params_A.state = state_A;
642 view()->OnNavigate(params_A); 640 view()->OnNavigate(params_A);
643 ProcessPendingMessages(); 641 ProcessPendingMessages();
644 642
645 // A new navigation commits, clearing the forward history. 643 // A new navigation commits, clearing the forward history.
646 LoadHTML("<div>Page C</div>"); 644 LoadHTML("<div>Page C</div>");
647 EXPECT_EQ(2, view()->history_list_length_); 645 EXPECT_EQ(2, view()->history_list_length_);
648 EXPECT_EQ(1, view()->history_list_offset_); 646 EXPECT_EQ(1, view()->history_list_offset_);
649 EXPECT_EQ(3, view()->history_page_ids_[1]); 647 EXPECT_EQ(3, view()->history_page_ids_[1]);
650 648
651 // The browser then sends a stale navigation to B, which should be ignored. 649 // The browser then sends a stale navigation to B, which should be ignored.
652 ViewMsg_Navigate_Params params_B; 650 ViewMsg_Navigate_Params params_B;
653 params_B.navigation_type = ViewMsg_Navigate_Type::NORMAL; 651 params_B.navigation_type = ViewMsg_Navigate_Type::NORMAL;
654 params_B.transition = content::PAGE_TRANSITION_FORWARD_BACK; 652 params_B.transition = PAGE_TRANSITION_FORWARD_BACK;
655 params_B.current_history_list_length = 2; 653 params_B.current_history_list_length = 2;
656 params_B.current_history_list_offset = 0; 654 params_B.current_history_list_offset = 0;
657 params_B.pending_history_list_offset = 1; 655 params_B.pending_history_list_offset = 1;
658 params_B.page_id = 2; 656 params_B.page_id = 2;
659 params_B.state = state_A; // Doesn't matter, just has to be present. 657 params_B.state = state_A; // Doesn't matter, just has to be present.
660 view()->OnNavigate(params_B); 658 view()->OnNavigate(params_B);
661 659
662 // State should be unchanged. 660 // State should be unchanged.
663 EXPECT_EQ(2, view()->history_list_length_); 661 EXPECT_EQ(2, view()->history_list_length_);
664 EXPECT_EQ(1, view()->history_list_offset_); 662 EXPECT_EQ(1, view()->history_list_offset_);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 std::string state_B; 706 std::string state_B;
709 ViewHostMsg_UpdateState::Read(msg_B, &page_id_B, &state_B); 707 ViewHostMsg_UpdateState::Read(msg_B, &page_id_B, &state_B);
710 EXPECT_EQ(2, page_id_B); 708 EXPECT_EQ(2, page_id_B);
711 render_thread_->sink().ClearMessages(); 709 render_thread_->sink().ClearMessages();
712 710
713 // Suppose the browser has limited the number of NavigationEntries to 2. 711 // Suppose the browser has limited the number of NavigationEntries to 2.
714 // It has now dropped the first entry, but the renderer isn't notified. 712 // It has now dropped the first entry, but the renderer isn't notified.
715 // Ensure that going back to page B (page_id 2) at offset 0 is successful. 713 // Ensure that going back to page B (page_id 2) at offset 0 is successful.
716 ViewMsg_Navigate_Params params_B; 714 ViewMsg_Navigate_Params params_B;
717 params_B.navigation_type = ViewMsg_Navigate_Type::NORMAL; 715 params_B.navigation_type = ViewMsg_Navigate_Type::NORMAL;
718 params_B.transition = content::PAGE_TRANSITION_FORWARD_BACK; 716 params_B.transition = PAGE_TRANSITION_FORWARD_BACK;
719 params_B.current_history_list_length = 2; 717 params_B.current_history_list_length = 2;
720 params_B.current_history_list_offset = 1; 718 params_B.current_history_list_offset = 1;
721 params_B.pending_history_list_offset = 0; 719 params_B.pending_history_list_offset = 0;
722 params_B.page_id = 2; 720 params_B.page_id = 2;
723 params_B.state = state_B; 721 params_B.state = state_B;
724 view()->OnNavigate(params_B); 722 view()->OnNavigate(params_B);
725 ProcessPendingMessages(); 723 ProcessPendingMessages();
726 724
727 EXPECT_EQ(2, view()->history_list_length_); 725 EXPECT_EQ(2, view()->history_list_length_);
728 EXPECT_EQ(0, view()->history_list_offset_); 726 EXPECT_EQ(0, view()->history_list_offset_);
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after
1693 EXPECT_EQ(0, bounds[i].width()); 1691 EXPECT_EQ(0, bounds[i].width());
1694 } else { 1692 } else {
1695 EXPECT_LT(0, bounds[i].width()); 1693 EXPECT_LT(0, bounds[i].width());
1696 } 1694 }
1697 } 1695 }
1698 view()->OnImeConfirmComposition(empty_string, ui::Range::InvalidRange()); 1696 view()->OnImeConfirmComposition(empty_string, ui::Range::InvalidRange());
1699 } 1697 }
1700 1698
1701 TEST_F(RenderViewImplTest, ZoomLimit) { 1699 TEST_F(RenderViewImplTest, ZoomLimit) {
1702 const double kMinZoomLevel = 1700 const double kMinZoomLevel =
1703 WebKit::WebView::zoomFactorToZoomLevel(content::kMinimumZoomFactor); 1701 WebKit::WebView::zoomFactorToZoomLevel(kMinimumZoomFactor);
1704 const double kMaxZoomLevel = 1702 const double kMaxZoomLevel =
1705 WebKit::WebView::zoomFactorToZoomLevel(content::kMaximumZoomFactor); 1703 WebKit::WebView::zoomFactorToZoomLevel(kMaximumZoomFactor);
1706 1704
1707 ViewMsg_Navigate_Params params; 1705 ViewMsg_Navigate_Params params;
1708 params.page_id = -1; 1706 params.page_id = -1;
1709 params.navigation_type = ViewMsg_Navigate_Type::NORMAL; 1707 params.navigation_type = ViewMsg_Navigate_Type::NORMAL;
1710 1708
1711 // Verifies navigation to a URL with preset zoom level indeed sets the level. 1709 // Verifies navigation to a URL with preset zoom level indeed sets the level.
1712 // Regression test for http://crbug.com/139559, where the level was not 1710 // Regression test for http://crbug.com/139559, where the level was not
1713 // properly set when it is out of the default zoom limits of WebView. 1711 // properly set when it is out of the default zoom limits of WebView.
1714 params.url = GURL("data:text/html,min_zoomlimit_test"); 1712 params.url = GURL("data:text/html,min_zoomlimit_test");
1715 view()->OnSetZoomLevelForLoadingURL(params.url, kMinZoomLevel); 1713 view()->OnSetZoomLevelForLoadingURL(params.url, kMinZoomLevel);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1783 EXPECT_EQ("abcdefgopqrstuvwxyz", info.value); 1781 EXPECT_EQ("abcdefgopqrstuvwxyz", info.value);
1784 EXPECT_EQ(7, info.selectionStart); 1782 EXPECT_EQ(7, info.selectionStart);
1785 EXPECT_EQ(7, info.selectionEnd); 1783 EXPECT_EQ(7, info.selectionEnd);
1786 view()->OnSetEditableSelectionOffsets(4, 8); 1784 view()->OnSetEditableSelectionOffsets(4, 8);
1787 view()->OnExtendSelectionAndDelete(2, 5); 1785 view()->OnExtendSelectionAndDelete(2, 5);
1788 info = view()->webview()->textInputInfo(); 1786 info = view()->webview()->textInputInfo();
1789 EXPECT_EQ("abuvwxyz", info.value); 1787 EXPECT_EQ("abuvwxyz", info.value);
1790 EXPECT_EQ(2, info.selectionStart); 1788 EXPECT_EQ(2, info.selectionStart);
1791 EXPECT_EQ(2, info.selectionEnd); 1789 EXPECT_EQ(2, info.selectionEnd);
1792 } 1790 }
1791
1792 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_thread_impl_unittest.cc ('k') | content/renderer/render_view_browsertest_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698