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

Side by Side Diff: third_party/WebKit/Source/web/tests/ChromeClientImplTest.cpp

Issue 2369613003: Require WebLocalFrame to be created with a non-null client (Closed)
Patch Set: oops Created 4 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
OLDNEW
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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 GetNavigationPolicyTest() 70 GetNavigationPolicyTest()
71 : m_result(WebNavigationPolicyIgnore) 71 : m_result(WebNavigationPolicyIgnore)
72 , m_webViewClient(&m_result) 72 , m_webViewClient(&m_result)
73 { 73 {
74 } 74 }
75 75
76 protected: 76 protected:
77 void SetUp() override 77 void SetUp() override
78 { 78 {
79 m_webView = toWebViewImpl(WebView::create(&m_webViewClient, WebPageVisib ilityStateVisible)); 79 m_webView = toWebViewImpl(WebView::create(&m_webViewClient, WebPageVisib ilityStateVisible));
80 m_mainFrame = WebLocalFrame::create(WebTreeScopeType::Document, &m_webFr ameClient); 80 m_webView->setMainFrame(WebLocalFrame::create(WebTreeScopeType::Document , &m_webFrameClient));
81 m_webView->setMainFrame(m_mainFrame);
82 m_chromeClientImpl = toChromeClientImpl(&m_webView->page()->chromeClient ()); 81 m_chromeClientImpl = toChromeClientImpl(&m_webView->page()->chromeClient ());
83 m_result = WebNavigationPolicyIgnore; 82 m_result = WebNavigationPolicyIgnore;
84 } 83 }
85 84
86 void TearDown() override 85 void TearDown() override
87 { 86 {
88 m_webView->close(); 87 m_webView->close();
89 m_mainFrame->close();
90 } 88 }
91 89
92 WebNavigationPolicy getNavigationPolicyWithMouseEvent(int modifiers, WebMous eEvent::Button button, bool asPopup) 90 WebNavigationPolicy getNavigationPolicyWithMouseEvent(int modifiers, WebMous eEvent::Button button, bool asPopup)
93 { 91 {
94 WebMouseEvent event; 92 WebMouseEvent event;
95 event.modifiers = modifiers; 93 event.modifiers = modifiers;
96 event.type = WebInputEvent::MouseUp; 94 event.type = WebInputEvent::MouseUp;
97 event.button = button; 95 event.button = button;
98 setCurrentInputEventForTest(&event); 96 setCurrentInputEventForTest(&event);
99 m_chromeClientImpl->setScrollbarsVisible(!asPopup); 97 m_chromeClientImpl->setScrollbarsVisible(!asPopup);
100 m_chromeClientImpl->show(NavigationPolicyIgnore); 98 m_chromeClientImpl->show(NavigationPolicyIgnore);
101 setCurrentInputEventForTest(0); 99 setCurrentInputEventForTest(0);
102 return m_result; 100 return m_result;
103 } 101 }
104 102
105 bool isNavigationPolicyPopup() 103 bool isNavigationPolicyPopup()
106 { 104 {
107 m_chromeClientImpl->show(NavigationPolicyIgnore); 105 m_chromeClientImpl->show(NavigationPolicyIgnore);
108 return m_result == WebNavigationPolicyNewPopup; 106 return m_result == WebNavigationPolicyNewPopup;
109 } 107 }
110 108
111 protected: 109 protected:
112 WebNavigationPolicy m_result; 110 WebNavigationPolicy m_result;
113 TestWebViewClient m_webViewClient; 111 TestWebViewClient m_webViewClient;
114 WebViewImpl* m_webView; 112 WebViewImpl* m_webView;
115 WebFrame* m_mainFrame;
116 FrameTestHelpers::TestWebFrameClient m_webFrameClient; 113 FrameTestHelpers::TestWebFrameClient m_webFrameClient;
117 Persistent<ChromeClientImpl> m_chromeClientImpl; 114 Persistent<ChromeClientImpl> m_chromeClientImpl;
118 }; 115 };
119 116
120 TEST_F(GetNavigationPolicyTest, LeftClick) 117 TEST_F(GetNavigationPolicyTest, LeftClick)
121 { 118 {
122 int modifiers = 0; 119 int modifiers = 0;
123 WebMouseEvent::Button button = WebMouseEvent::Button::Left; 120 WebMouseEvent::Button button = WebMouseEvent::Button::Left;
124 bool asPopup = false; 121 bool asPopup = false;
125 EXPECT_EQ(WebNavigationPolicyNewForegroundTab, 122 EXPECT_EQ(WebNavigationPolicyNewForegroundTab,
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 { 271 {
275 m_webView = toWebViewImpl(WebView::create(&m_webViewClient, WebPageVisib ilityStateVisible)); 272 m_webView = toWebViewImpl(WebView::create(&m_webViewClient, WebPageVisib ilityStateVisible));
276 m_mainFrame = WebLocalFrame::create(WebTreeScopeType::Document, &m_webFr ameClient); 273 m_mainFrame = WebLocalFrame::create(WebTreeScopeType::Document, &m_webFr ameClient);
277 m_webView->setMainFrame(m_mainFrame); 274 m_webView->setMainFrame(m_mainFrame);
278 m_chromeClientImpl = toChromeClientImpl(&m_webView->page()->chromeClient ()); 275 m_chromeClientImpl = toChromeClientImpl(&m_webView->page()->chromeClient ());
279 } 276 }
280 277
281 void TearDown() override 278 void TearDown() override
282 { 279 {
283 m_webView->close(); 280 m_webView->close();
284 m_mainFrame->close();
285 } 281 }
286 282
287 ViewCreatingClient m_webViewClient; 283 ViewCreatingClient m_webViewClient;
288 WebViewImpl* m_webView; 284 WebViewImpl* m_webView;
289 WebFrame* m_mainFrame; 285 WebLocalFrame* m_mainFrame;
290 FrameTestHelpers::TestWebFrameClient m_webFrameClient; 286 FrameTestHelpers::TestWebFrameClient m_webFrameClient;
291 Persistent<ChromeClientImpl> m_chromeClientImpl; 287 Persistent<ChromeClientImpl> m_chromeClientImpl;
292 }; 288 };
293 289
294 TEST_F(CreateWindowTest, CreateWindowFromDeferredPage) 290 TEST_F(CreateWindowTest, CreateWindowFromDeferredPage)
295 { 291 {
296 m_webView->page()->setDefersLoading(true); 292 m_webView->page()->setDefersLoading(true);
297 LocalFrame* frame = toWebLocalFrameImpl(m_mainFrame)->frame(); 293 LocalFrame* frame = toWebLocalFrameImpl(m_mainFrame)->frame();
298 FrameLoadRequest request(frame->document()); 294 FrameLoadRequest request(frame->document());
299 WindowFeatures features; 295 WindowFeatures features;
300 EXPECT_EQ(nullptr, m_chromeClientImpl->createWindow(frame, request, features , NavigationPolicyNewForegroundTab)); 296 EXPECT_EQ(nullptr, m_chromeClientImpl->createWindow(frame, request, features , NavigationPolicyNewForegroundTab));
301 m_webView->page()->setDefersLoading(false); 297 m_webView->page()->setDefersLoading(false);
302 } 298 }
303 299
304 } // namespace blink 300 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698