OLD | NEW |
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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 { | 184 { |
185 return m_chooserCompletion; | 185 return m_chooserCompletion; |
186 } | 186 } |
187 | 187 |
188 void clearChooserCompletion() | 188 void clearChooserCompletion() |
189 { | 189 { |
190 m_chooserCompletion = 0; | 190 m_chooserCompletion = 0; |
191 } | 191 } |
192 | 192 |
193 // WebViewClient methods | 193 // WebViewClient methods |
194 virtual bool openDateTimeChooser(const WebDateTimeChooserParams&, WebDateTim
eChooserCompletion* chooser_completion) OVERRIDE | 194 virtual bool openDateTimeChooser(const WebDateTimeChooserParams&, WebDateTim
eChooserCompletion* chooser_completion) override |
195 { | 195 { |
196 m_chooserCompletion = chooser_completion; | 196 m_chooserCompletion = chooser_completion; |
197 return true; | 197 return true; |
198 } | 198 } |
199 | 199 |
200 private: | 200 private: |
201 WebDateTimeChooserCompletion* m_chooserCompletion; | 201 WebDateTimeChooserCompletion* m_chooserCompletion; |
202 | 202 |
203 }; | 203 }; |
204 | 204 |
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
960 } | 960 } |
961 | 961 |
962 class PrintWebViewClient : public FrameTestHelpers::TestWebViewClient { | 962 class PrintWebViewClient : public FrameTestHelpers::TestWebViewClient { |
963 public: | 963 public: |
964 PrintWebViewClient() | 964 PrintWebViewClient() |
965 : m_printCalled(false) | 965 : m_printCalled(false) |
966 { | 966 { |
967 } | 967 } |
968 | 968 |
969 // WebViewClient methods | 969 // WebViewClient methods |
970 virtual void printPage(WebLocalFrame*) OVERRIDE | 970 virtual void printPage(WebLocalFrame*) override |
971 { | 971 { |
972 m_printCalled = true; | 972 m_printCalled = true; |
973 } | 973 } |
974 | 974 |
975 bool printCalled() const { return m_printCalled; } | 975 bool printCalled() const { return m_printCalled; } |
976 | 976 |
977 private: | 977 private: |
978 bool m_printCalled; | 978 bool m_printCalled; |
979 }; | 979 }; |
980 | 980 |
981 | 981 |
982 TEST_F(WebViewTest, PrintWithXHRInFlight) | 982 TEST_F(WebViewTest, PrintWithXHRInFlight) |
983 { | 983 { |
984 PrintWebViewClient client; | 984 PrintWebViewClient client; |
985 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("print_with_xhr_inflight.html")); | 985 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("print_with_xhr_inflight.html")); |
986 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + "pr
int_with_xhr_inflight.html", true, 0, &client); | 986 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + "pr
int_with_xhr_inflight.html", true, 0, &client); |
987 | 987 |
988 ASSERT_EQ(FrameStateComplete, toLocalFrame(webViewImpl->page()->mainFrame())
->loader().state()); | 988 ASSERT_EQ(FrameStateComplete, toLocalFrame(webViewImpl->page()->mainFrame())
->loader().state()); |
989 EXPECT_TRUE(client.printCalled()); | 989 EXPECT_TRUE(client.printCalled()); |
990 m_webViewHelper.reset(); | 990 m_webViewHelper.reset(); |
991 } | 991 } |
992 | 992 |
993 class DropTask : public WebThread::Task { | 993 class DropTask : public WebThread::Task { |
994 public: | 994 public: |
995 explicit DropTask(WebView* webView) : m_webView(webView) | 995 explicit DropTask(WebView* webView) : m_webView(webView) |
996 { | 996 { |
997 } | 997 } |
998 | 998 |
999 virtual void run() OVERRIDE | 999 virtual void run() override |
1000 { | 1000 { |
1001 const WebPoint clientPoint(0, 0); | 1001 const WebPoint clientPoint(0, 0); |
1002 const WebPoint screenPoint(0, 0); | 1002 const WebPoint screenPoint(0, 0); |
1003 m_webView->dragTargetDrop(clientPoint, screenPoint, 0); | 1003 m_webView->dragTargetDrop(clientPoint, screenPoint, 0); |
1004 } | 1004 } |
1005 | 1005 |
1006 private: | 1006 private: |
1007 WebView* const m_webView; | 1007 WebView* const m_webView; |
1008 }; | 1008 }; |
1009 static void DragAndDropURL(WebViewImpl* webView, const std::string& url) | 1009 static void DragAndDropURL(WebViewImpl* webView, const std::string& url) |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1049 | 1049 |
1050 // Attempt to drag and drop to barUrl and verify that no navigation has occu
rred. | 1050 // Attempt to drag and drop to barUrl and verify that no navigation has occu
rred. |
1051 DragAndDropURL(webView, barUrl); | 1051 DragAndDropURL(webView, barUrl); |
1052 EXPECT_EQ(fooUrl, webView->mainFrame()->document().url().string().utf8()); | 1052 EXPECT_EQ(fooUrl, webView->mainFrame()->document().url().string().utf8()); |
1053 } | 1053 } |
1054 | 1054 |
1055 class ContentDetectorClient : public FrameTestHelpers::TestWebViewClient { | 1055 class ContentDetectorClient : public FrameTestHelpers::TestWebViewClient { |
1056 public: | 1056 public: |
1057 ContentDetectorClient() { reset(); } | 1057 ContentDetectorClient() { reset(); } |
1058 | 1058 |
1059 virtual WebContentDetectionResult detectContentAround(const WebHitTestResult
& hitTest) OVERRIDE | 1059 virtual WebContentDetectionResult detectContentAround(const WebHitTestResult
& hitTest) override |
1060 { | 1060 { |
1061 m_contentDetectionRequested = true; | 1061 m_contentDetectionRequested = true; |
1062 return m_contentDetectionResult; | 1062 return m_contentDetectionResult; |
1063 } | 1063 } |
1064 | 1064 |
1065 virtual void scheduleContentIntent(const WebURL& url) OVERRIDE | 1065 virtual void scheduleContentIntent(const WebURL& url) override |
1066 { | 1066 { |
1067 m_scheduledIntentURL = url; | 1067 m_scheduledIntentURL = url; |
1068 } | 1068 } |
1069 | 1069 |
1070 virtual void cancelScheduledContentIntents() OVERRIDE | 1070 virtual void cancelScheduledContentIntents() override |
1071 { | 1071 { |
1072 m_pendingIntentsCancelled = true; | 1072 m_pendingIntentsCancelled = true; |
1073 } | 1073 } |
1074 | 1074 |
1075 void reset() | 1075 void reset() |
1076 { | 1076 { |
1077 m_contentDetectionRequested = false; | 1077 m_contentDetectionRequested = false; |
1078 m_pendingIntentsCancelled = false; | 1078 m_pendingIntentsCancelled = false; |
1079 m_scheduledIntentURL = WebURL(); | 1079 m_scheduledIntentURL = WebURL(); |
1080 m_contentDetectionResult = WebContentDetectionResult(); | 1080 m_contentDetectionResult = WebContentDetectionResult(); |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1303 class MockAutofillClient : public WebAutofillClient { | 1303 class MockAutofillClient : public WebAutofillClient { |
1304 public: | 1304 public: |
1305 MockAutofillClient() | 1305 MockAutofillClient() |
1306 : m_ignoreTextChanges(false) | 1306 : m_ignoreTextChanges(false) |
1307 , m_textChangesWhileIgnored(0) | 1307 , m_textChangesWhileIgnored(0) |
1308 , m_textChangesWhileNotIgnored(0) | 1308 , m_textChangesWhileNotIgnored(0) |
1309 , m_userGestureNotificationsCount(0) { } | 1309 , m_userGestureNotificationsCount(0) { } |
1310 | 1310 |
1311 virtual ~MockAutofillClient() { } | 1311 virtual ~MockAutofillClient() { } |
1312 | 1312 |
1313 virtual void setIgnoreTextChanges(bool ignore) OVERRIDE { m_ignoreTextChange
s = ignore; } | 1313 virtual void setIgnoreTextChanges(bool ignore) override { m_ignoreTextChange
s = ignore; } |
1314 virtual void textFieldDidChange(const WebFormControlElement&) OVERRIDE | 1314 virtual void textFieldDidChange(const WebFormControlElement&) override |
1315 { | 1315 { |
1316 if (m_ignoreTextChanges) | 1316 if (m_ignoreTextChanges) |
1317 ++m_textChangesWhileIgnored; | 1317 ++m_textChangesWhileIgnored; |
1318 else | 1318 else |
1319 ++m_textChangesWhileNotIgnored; | 1319 ++m_textChangesWhileNotIgnored; |
1320 } | 1320 } |
1321 virtual void firstUserGestureObserved() OVERRIDE { ++m_userGestureNotificati
onsCount; } | 1321 virtual void firstUserGestureObserved() override { ++m_userGestureNotificati
onsCount; } |
1322 | 1322 |
1323 void clearChangeCounts() | 1323 void clearChangeCounts() |
1324 { | 1324 { |
1325 m_textChangesWhileIgnored = 0; | 1325 m_textChangesWhileIgnored = 0; |
1326 m_textChangesWhileNotIgnored = 0; | 1326 m_textChangesWhileNotIgnored = 0; |
1327 } | 1327 } |
1328 | 1328 |
1329 int textChangesWhileIgnored() { return m_textChangesWhileIgnored; } | 1329 int textChangesWhileIgnored() { return m_textChangesWhileIgnored; } |
1330 int textChangesWhileNotIgnored() { return m_textChangesWhileNotIgnored; } | 1330 int textChangesWhileNotIgnored() { return m_textChangesWhileNotIgnored; } |
1331 int getUserGestureNotificationsCount() { return m_userGestureNotificationsCo
unt; } | 1331 int getUserGestureNotificationsCount() { return m_userGestureNotificationsCo
unt; } |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1444 } | 1444 } |
1445 | 1445 |
1446 class ViewCreatingWebViewClient : public FrameTestHelpers::TestWebViewClient { | 1446 class ViewCreatingWebViewClient : public FrameTestHelpers::TestWebViewClient { |
1447 public: | 1447 public: |
1448 ViewCreatingWebViewClient() | 1448 ViewCreatingWebViewClient() |
1449 : m_didFocusCalled(false) | 1449 : m_didFocusCalled(false) |
1450 { | 1450 { |
1451 } | 1451 } |
1452 | 1452 |
1453 // WebViewClient methods | 1453 // WebViewClient methods |
1454 virtual WebView* createView(WebLocalFrame*, const WebURLRequest&, const WebW
indowFeatures&, const WebString& name, WebNavigationPolicy, bool) OVERRIDE | 1454 virtual WebView* createView(WebLocalFrame*, const WebURLRequest&, const WebW
indowFeatures&, const WebString& name, WebNavigationPolicy, bool) override |
1455 { | 1455 { |
1456 return m_webViewHelper.initialize(true, 0, 0); | 1456 return m_webViewHelper.initialize(true, 0, 0); |
1457 } | 1457 } |
1458 | 1458 |
1459 // WebWidgetClient methods | 1459 // WebWidgetClient methods |
1460 virtual void didFocus() OVERRIDE | 1460 virtual void didFocus() override |
1461 { | 1461 { |
1462 m_didFocusCalled = true; | 1462 m_didFocusCalled = true; |
1463 } | 1463 } |
1464 | 1464 |
1465 bool didFocusCalled() const { return m_didFocusCalled; } | 1465 bool didFocusCalled() const { return m_didFocusCalled; } |
1466 WebView* createdWebView() const { return m_webViewHelper.webView(); } | 1466 WebView* createdWebView() const { return m_webViewHelper.webView(); } |
1467 | 1467 |
1468 private: | 1468 private: |
1469 FrameTestHelpers::WebViewHelper m_webViewHelper; | 1469 FrameTestHelpers::WebViewHelper m_webViewHelper; |
1470 bool m_didFocusCalled; | 1470 bool m_didFocusCalled; |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1671 webView->layout(); | 1671 webView->layout(); |
1672 WebRect cropRect(0, 0, 100, 100); | 1672 WebRect cropRect(0, 0, 100, 100); |
1673 webView->extractSmartClipData(cropRect, clipText, clipHtml, clipRect); | 1673 webView->extractSmartClipData(cropRect, clipText, clipHtml, clipRect); |
1674 EXPECT_STREQ("", clipText.utf8().c_str()); | 1674 EXPECT_STREQ("", clipText.utf8().c_str()); |
1675 EXPECT_STREQ("", clipHtml.utf8().c_str()); | 1675 EXPECT_STREQ("", clipHtml.utf8().c_str()); |
1676 } | 1676 } |
1677 | 1677 |
1678 class CreateChildCounterFrameClient : public FrameTestHelpers::TestWebFrameClien
t { | 1678 class CreateChildCounterFrameClient : public FrameTestHelpers::TestWebFrameClien
t { |
1679 public: | 1679 public: |
1680 CreateChildCounterFrameClient() : m_count(0) { } | 1680 CreateChildCounterFrameClient() : m_count(0) { } |
1681 virtual WebFrame* createChildFrame(WebLocalFrame* parent, const WebString& f
rameName) OVERRIDE; | 1681 virtual WebFrame* createChildFrame(WebLocalFrame* parent, const WebString& f
rameName) override; |
1682 | 1682 |
1683 int count() const { return m_count; } | 1683 int count() const { return m_count; } |
1684 | 1684 |
1685 private: | 1685 private: |
1686 int m_count; | 1686 int m_count; |
1687 }; | 1687 }; |
1688 | 1688 |
1689 WebFrame* CreateChildCounterFrameClient::createChildFrame(WebLocalFrame* parent,
const WebString& frameName) | 1689 WebFrame* CreateChildCounterFrameClient::createChildFrame(WebLocalFrame* parent,
const WebString& frameName) |
1690 { | 1690 { |
1691 ++m_count; | 1691 ++m_count; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1728 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("add_frame_in_unload.html")); | 1728 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("add_frame_in_unload.html")); |
1729 m_webViewHelper.initializeAndLoad(m_baseURL + "add_frame_in_unload_wrapper.h
tml", true, &frameClient); | 1729 m_webViewHelper.initializeAndLoad(m_baseURL + "add_frame_in_unload_wrapper.h
tml", true, &frameClient); |
1730 FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(), "about:b
lank"); | 1730 FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(), "about:b
lank"); |
1731 EXPECT_EQ(1, frameClient.count()); | 1731 EXPECT_EQ(1, frameClient.count()); |
1732 m_webViewHelper.reset(); | 1732 m_webViewHelper.reset(); |
1733 } | 1733 } |
1734 | 1734 |
1735 class TouchEventHandlerWebViewClient : public FrameTestHelpers::TestWebViewClien
t { | 1735 class TouchEventHandlerWebViewClient : public FrameTestHelpers::TestWebViewClien
t { |
1736 public: | 1736 public: |
1737 // WebWidgetClient methods | 1737 // WebWidgetClient methods |
1738 virtual void hasTouchEventHandlers(bool state) OVERRIDE | 1738 virtual void hasTouchEventHandlers(bool state) override |
1739 { | 1739 { |
1740 m_hasTouchEventHandlerCount[state]++; | 1740 m_hasTouchEventHandlerCount[state]++; |
1741 } | 1741 } |
1742 | 1742 |
1743 // Local methods | 1743 // Local methods |
1744 TouchEventHandlerWebViewClient() : m_hasTouchEventHandlerCount() | 1744 TouchEventHandlerWebViewClient() : m_hasTouchEventHandlerCount() |
1745 { | 1745 { |
1746 } | 1746 } |
1747 | 1747 |
1748 int getAndResetHasTouchEventHandlerCallCount(bool state) | 1748 int getAndResetHasTouchEventHandlerCallCount(bool state) |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2019 WebRect actualRootBounds; | 2019 WebRect actualRootBounds; |
2020 webView->getSelectionRootBounds(actualRootBounds); | 2020 webView->getSelectionRootBounds(actualRootBounds); |
2021 ASSERT_EQ(expectedRootBounds, actualRootBounds); | 2021 ASSERT_EQ(expectedRootBounds, actualRootBounds); |
2022 } | 2022 } |
2023 | 2023 |
2024 class NonUserInputTextUpdateWebViewClient : public FrameTestHelpers::TestWebView
Client { | 2024 class NonUserInputTextUpdateWebViewClient : public FrameTestHelpers::TestWebView
Client { |
2025 public: | 2025 public: |
2026 NonUserInputTextUpdateWebViewClient() : m_textIsUpdated(false) { } | 2026 NonUserInputTextUpdateWebViewClient() : m_textIsUpdated(false) { } |
2027 | 2027 |
2028 // WebWidgetClient methods | 2028 // WebWidgetClient methods |
2029 virtual void didUpdateTextOfFocusedElementByNonUserInput() OVERRIDE | 2029 virtual void didUpdateTextOfFocusedElementByNonUserInput() override |
2030 { | 2030 { |
2031 m_textIsUpdated = true; | 2031 m_textIsUpdated = true; |
2032 } | 2032 } |
2033 | 2033 |
2034 void reset() | 2034 void reset() |
2035 { | 2035 { |
2036 m_textIsUpdated = false; | 2036 m_textIsUpdated = false; |
2037 } | 2037 } |
2038 | 2038 |
2039 bool textIsUpdated() const | 2039 bool textIsUpdated() const |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2216 loadFrame(webView->mainFrame(), url); | 2216 loadFrame(webView->mainFrame(), url); |
2217 | 2217 |
2218 FrameView* frameView = m_webViewHelper.webViewImpl()->mainFrameImpl()->frame
View(); | 2218 FrameView* frameView = m_webViewHelper.webViewImpl()->mainFrameImpl()->frame
View(); |
2219 | 2219 |
2220 // Auto-resizing used to ASSERT(needsLayout()) in RenderBlockFlow::layout. T
his EXPECT is | 2220 // Auto-resizing used to ASSERT(needsLayout()) in RenderBlockFlow::layout. T
his EXPECT is |
2221 // merely a dummy. The real test is that we don't trigger asserts in debug b
uilds. | 2221 // merely a dummy. The real test is that we don't trigger asserts in debug b
uilds. |
2222 EXPECT_FALSE(frameView->needsLayout()); | 2222 EXPECT_FALSE(frameView->needsLayout()); |
2223 }; | 2223 }; |
2224 | 2224 |
2225 } // namespace | 2225 } // namespace |
OLD | NEW |