OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 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 12 matching lines...) Expand all Loading... |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 | 32 |
| 33 #include "WebFrame.h" |
33 #include "WebFrameClient.h" | 34 #include "WebFrameClient.h" |
34 #include "WebInputEvent.h" | 35 #include "WebInputEvent.h" |
35 #include "WebView.h" | 36 #include "WebView.h" |
36 #include "WebViewClient.h" | 37 #include "WebViewClient.h" |
37 #include "WebViewImpl.h" | 38 #include "WebViewImpl.h" |
38 #include "core/page/Chrome.h" | 39 #include "core/page/Chrome.h" |
39 #include <gtest/gtest.h> | 40 #include <gtest/gtest.h> |
40 | 41 |
41 using namespace WebKit; | 42 using namespace WebKit; |
42 | 43 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 GetNavigationPolicyTest() | 81 GetNavigationPolicyTest() |
81 : m_result(WebNavigationPolicyIgnore) | 82 : m_result(WebNavigationPolicyIgnore) |
82 , m_webViewClient(&m_result) | 83 , m_webViewClient(&m_result) |
83 { | 84 { |
84 } | 85 } |
85 | 86 |
86 protected: | 87 protected: |
87 virtual void SetUp() | 88 virtual void SetUp() |
88 { | 89 { |
89 m_webView = toWebViewImpl(WebView::create(&m_webViewClient)); | 90 m_webView = toWebViewImpl(WebView::create(&m_webViewClient)); |
90 m_webView->initializeMainFrame(&m_webFrameClient); | 91 m_mainFrame = WebFrame::create(&m_webFrameClient); |
| 92 m_webView->setMainFrame(m_mainFrame); |
91 m_chromeClientImpl = static_cast<ChromeClientImpl*>(&m_webView->page()->
chrome().client()); | 93 m_chromeClientImpl = static_cast<ChromeClientImpl*>(&m_webView->page()->
chrome().client()); |
92 m_result = WebNavigationPolicyIgnore; | 94 m_result = WebNavigationPolicyIgnore; |
93 } | 95 } |
94 | 96 |
95 virtual void TearDown() | 97 virtual void TearDown() |
96 { | 98 { |
97 m_webView->close(); | 99 m_webView->close(); |
| 100 m_mainFrame->close(); |
98 } | 101 } |
99 | 102 |
100 WebNavigationPolicy getNavigationPolicyWithMouseEvent(int modifiers, WebMous
eEvent::Button button, bool asPopup) | 103 WebNavigationPolicy getNavigationPolicyWithMouseEvent(int modifiers, WebMous
eEvent::Button button, bool asPopup) |
101 { | 104 { |
102 WebMouseEvent event; | 105 WebMouseEvent event; |
103 event.modifiers = modifiers; | 106 event.modifiers = modifiers; |
104 event.type = WebInputEvent::MouseUp; | 107 event.type = WebInputEvent::MouseUp; |
105 event.button = button; | 108 event.button = button; |
106 setCurrentInputEventForTest(&event); | 109 setCurrentInputEventForTest(&event); |
107 m_chromeClientImpl->setScrollbarsVisible(!asPopup); | 110 m_chromeClientImpl->setScrollbarsVisible(!asPopup); |
108 m_chromeClientImpl->show(WebCore::NavigationPolicyIgnore); | 111 m_chromeClientImpl->show(WebCore::NavigationPolicyIgnore); |
109 setCurrentInputEventForTest(0); | 112 setCurrentInputEventForTest(0); |
110 return m_result; | 113 return m_result; |
111 } | 114 } |
112 | 115 |
113 bool isNavigationPolicyPopup() | 116 bool isNavigationPolicyPopup() |
114 { | 117 { |
115 m_chromeClientImpl->show(WebCore::NavigationPolicyIgnore); | 118 m_chromeClientImpl->show(WebCore::NavigationPolicyIgnore); |
116 return m_result == WebNavigationPolicyNewPopup; | 119 return m_result == WebNavigationPolicyNewPopup; |
117 } | 120 } |
118 | 121 |
119 protected: | 122 protected: |
120 WebNavigationPolicy m_result; | 123 WebNavigationPolicy m_result; |
121 TestWebViewClient m_webViewClient; | 124 TestWebViewClient m_webViewClient; |
122 WebViewImpl* m_webView; | 125 WebViewImpl* m_webView; |
| 126 WebFrame* m_mainFrame; |
123 TestWebFrameClient m_webFrameClient; | 127 TestWebFrameClient m_webFrameClient; |
124 ChromeClientImpl* m_chromeClientImpl; | 128 ChromeClientImpl* m_chromeClientImpl; |
125 }; | 129 }; |
126 | 130 |
127 TEST_F(GetNavigationPolicyTest, LeftClick) | 131 TEST_F(GetNavigationPolicyTest, LeftClick) |
128 { | 132 { |
129 int modifiers = 0; | 133 int modifiers = 0; |
130 WebMouseEvent::Button button = WebMouseEvent::ButtonLeft; | 134 WebMouseEvent::Button button = WebMouseEvent::ButtonLeft; |
131 bool asPopup = false; | 135 bool asPopup = false; |
132 EXPECT_EQ(WebNavigationPolicyNewForegroundTab, | 136 EXPECT_EQ(WebNavigationPolicyNewForegroundTab, |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 | 262 |
259 TEST_F(GetNavigationPolicyTest, NotResizableForcesPopup) | 263 TEST_F(GetNavigationPolicyTest, NotResizableForcesPopup) |
260 { | 264 { |
261 m_chromeClientImpl->setResizable(false); | 265 m_chromeClientImpl->setResizable(false); |
262 EXPECT_TRUE(isNavigationPolicyPopup()); | 266 EXPECT_TRUE(isNavigationPolicyPopup()); |
263 m_chromeClientImpl->setResizable(true); | 267 m_chromeClientImpl->setResizable(true); |
264 EXPECT_FALSE(isNavigationPolicyPopup()); | 268 EXPECT_FALSE(isNavigationPolicyPopup()); |
265 } | 269 } |
266 | 270 |
267 } // namespace | 271 } // namespace |
OLD | NEW |