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

Side by Side Diff: Source/web/tests/WebViewTest.cpp

Issue 336553003: Change Page::m_mainFrame to be a Frame. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/web/tests/WebInputEventConversionTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 webViewImpl->layout(); 786 webViewImpl->layout();
787 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); 787 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width);
788 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); 788 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height);
789 789
790 // Make the page scale and scroll with the given paremeters. 790 // Make the page scale and scroll with the given paremeters.
791 webViewImpl->setPageScaleFactor(2.0f); 791 webViewImpl->setPageScaleFactor(2.0f);
792 webViewImpl->setMainFrameScrollOffset(WebPoint(116, 84)); 792 webViewImpl->setMainFrameScrollOffset(WebPoint(116, 84));
793 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); 793 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor());
794 EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width); 794 EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width);
795 EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height); 795 EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height);
796 webViewImpl->page()->mainFrame()->loader().saveScrollState(); 796 WebCore::LocalFrame* mainFrameLocal = toLocalFrame(webViewImpl->page()->main Frame());
797 EXPECT_EQ(2.0f, webViewImpl->page()->mainFrame()->loader().currentItem()->pa geScaleFactor()); 797 mainFrameLocal->loader().saveScrollState();
798 EXPECT_EQ(116, webViewImpl->page()->mainFrame()->loader().currentItem()->scr ollPoint().x()); 798 EXPECT_EQ(2.0f, mainFrameLocal->loader().currentItem()->pageScaleFactor());
799 EXPECT_EQ(84, webViewImpl->page()->mainFrame()->loader().currentItem()->scro llPoint().y()); 799 EXPECT_EQ(116, mainFrameLocal->loader().currentItem()->scrollPoint().x());
800 EXPECT_EQ(84, mainFrameLocal->loader().currentItem()->scrollPoint().y());
800 801
801 // Confirm that resetting the page state resets the saved scroll position. 802 // Confirm that resetting the page state resets the saved scroll position.
802 // The HistoryController treats a page scale factor of 0.0f as special and a voids 803 // The HistoryController treats a page scale factor of 0.0f as special and a voids
803 // restoring it to the WebView. 804 // restoring it to the WebView.
804 webViewImpl->resetScrollAndScaleState(); 805 webViewImpl->resetScrollAndScaleState();
805 EXPECT_EQ(1.0f, webViewImpl->pageScaleFactor()); 806 EXPECT_EQ(1.0f, webViewImpl->pageScaleFactor());
806 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); 807 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width);
807 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); 808 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height);
808 EXPECT_EQ(0.0f, webViewImpl->page()->mainFrame()->loader().currentItem()->pa geScaleFactor()); 809 EXPECT_EQ(0.0f, mainFrameLocal->loader().currentItem()->pageScaleFactor());
809 EXPECT_EQ(0, webViewImpl->page()->mainFrame()->loader().currentItem()->scrol lPoint().x()); 810 EXPECT_EQ(0, mainFrameLocal->loader().currentItem()->scrollPoint().x());
810 EXPECT_EQ(0, webViewImpl->page()->mainFrame()->loader().currentItem()->scrol lPoint().y()); 811 EXPECT_EQ(0, mainFrameLocal->loader().currentItem()->scrollPoint().y());
811 } 812 }
812 813
813 class EnterFullscreenWebViewClient : public FrameTestHelpers::TestWebViewClient { 814 class EnterFullscreenWebViewClient : public FrameTestHelpers::TestWebViewClient {
814 public: 815 public:
815 // WebViewClient methods 816 // WebViewClient methods
816 virtual bool enterFullScreen() { return true; } 817 virtual bool enterFullScreen() { return true; }
817 virtual void exitFullScreen() { } 818 virtual void exitFullScreen() { }
818 }; 819 };
819 820
820 821
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 bool m_printCalled; 878 bool m_printCalled;
878 }; 879 };
879 880
880 881
881 TEST_F(WebViewTest, PrintWithXHRInFlight) 882 TEST_F(WebViewTest, PrintWithXHRInFlight)
882 { 883 {
883 PrintWebViewClient client; 884 PrintWebViewClient client;
884 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("print_with_xhr_inflight.html")); 885 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("print_with_xhr_inflight.html"));
885 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + "pr int_with_xhr_inflight.html", true, 0, &client); 886 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + "pr int_with_xhr_inflight.html", true, 0, &client);
886 887
887 ASSERT_EQ(WebCore::FrameStateComplete, webViewImpl->page()->mainFrame()->loa der().state()); 888 ASSERT_EQ(WebCore::FrameStateComplete, toLocalFrame(webViewImpl->page()->mai nFrame())->loader().state());
888 EXPECT_TRUE(client.printCalled()); 889 EXPECT_TRUE(client.printCalled());
889 m_webViewHelper.reset(); 890 m_webViewHelper.reset();
890 } 891 }
891 892
892 class DropTask : public WebThread::Task { 893 class DropTask : public WebThread::Task {
893 public: 894 public:
894 explicit DropTask(WebView* webView) : m_webView(webView) 895 explicit DropTask(WebView* webView) : m_webView(webView)
895 { 896 {
896 } 897 }
897 898
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 FrameTestHelpers::WebViewHelper m_webViewHelper; 1355 FrameTestHelpers::WebViewHelper m_webViewHelper;
1355 WebViewImpl* webViewImpl = m_webViewHelper.initialize(true, 0, &client); 1356 WebViewImpl* webViewImpl = m_webViewHelper.initialize(true, 0, &client);
1356 webViewImpl->page()->settings().setJavaScriptCanOpenWindowsAutomatically(tru e); 1357 webViewImpl->page()->settings().setJavaScriptCanOpenWindowsAutomatically(tru e);
1357 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewImpl->mainFrame()); 1358 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewImpl->mainFrame());
1358 frame->setName("_start"); 1359 frame->setName("_start");
1359 1360
1360 // Make a request that will open a new window 1361 // Make a request that will open a new window
1361 WebURLRequest webURLRequest; 1362 WebURLRequest webURLRequest;
1362 webURLRequest.initialize(); 1363 webURLRequest.initialize();
1363 WebCore::FrameLoadRequest request(0, webURLRequest.toResourceRequest(), "_bl ank"); 1364 WebCore::FrameLoadRequest request(0, webURLRequest.toResourceRequest(), "_bl ank");
1364 webViewImpl->page()->mainFrame()->loader().load(request); 1365 toLocalFrame(webViewImpl->page()->mainFrame())->loader().load(request);
1365 ASSERT_TRUE(client.createdWebView()); 1366 ASSERT_TRUE(client.createdWebView());
1366 EXPECT_FALSE(client.didFocusCalled()); 1367 EXPECT_FALSE(client.didFocusCalled());
1367 1368
1368 // Make a request from the new window that will navigate the original window . The original window should be focused. 1369 // Make a request from the new window that will navigate the original window . The original window should be focused.
1369 WebURLRequest webURLRequestWithTargetStart; 1370 WebURLRequest webURLRequestWithTargetStart;
1370 webURLRequestWithTargetStart.initialize(); 1371 webURLRequestWithTargetStart.initialize();
1371 WebCore::FrameLoadRequest requestWithTargetStart(0, webURLRequestWithTargetS tart.toResourceRequest(), "_start"); 1372 WebCore::FrameLoadRequest requestWithTargetStart(0, webURLRequestWithTargetS tart.toResourceRequest(), "_start");
1372 toWebViewImpl(client.createdWebView())->page()->mainFrame()->loader().load(r equestWithTargetStart); 1373 toLocalFrame(toWebViewImpl(client.createdWebView())->page()->mainFrame())->l oader().load(requestWithTargetStart);
1373 EXPECT_TRUE(client.didFocusCalled()); 1374 EXPECT_TRUE(client.didFocusCalled());
1374 1375
1375 m_webViewHelper.reset(); // Remove dependency on locally scoped client. 1376 m_webViewHelper.reset(); // Remove dependency on locally scoped client.
1376 } 1377 }
1377 1378
1378 TEST_F(WebViewTest, DispatchesFocusOutFocusInOnViewToggleFocus) 1379 TEST_F(WebViewTest, DispatchesFocusOutFocusInOnViewToggleFocus)
1379 { 1380 {
1380 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), "focusout_focusin_events.html"); 1381 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), "focusout_focusin_events.html");
1381 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "focusout_f ocusin_events.html", true, 0); 1382 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "focusout_f ocusin_events.html", true, 0);
1382 1383
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
1995 1996
1996 EXPECT_EQ(0, client.getUserGestureNotificationsCount()); 1997 EXPECT_EQ(0, client.getUserGestureNotificationsCount());
1997 1998
1998 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr omUTF8("target"))); 1999 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr omUTF8("target")));
1999 2000
2000 EXPECT_EQ(1, client.getUserGestureNotificationsCount()); 2001 EXPECT_EQ(1, client.getUserGestureNotificationsCount());
2001 webView->setAutofillClient(0); 2002 webView->setAutofillClient(0);
2002 } 2003 }
2003 2004
2004 } // namespace 2005 } // namespace
OLDNEW
« no previous file with comments | « Source/web/tests/WebInputEventConversionTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698