Chromium Code Reviews| 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 18 matching lines...) Expand all Loading... | |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "WebView.h" | 32 #include "WebView.h" |
| 33 | 33 |
| 34 #include <gtest/gtest.h> | 34 #include <gtest/gtest.h> |
| 35 #include "FrameTestHelpers.h" | 35 #include "FrameTestHelpers.h" |
| 36 #include "URLTestHelpers.h" | 36 #include "URLTestHelpers.h" |
| 37 #include "WebAutofillClient.h" | 37 #include "WebAutofillClient.h" |
| 38 #include "WebContentDetectionResult.h" | 38 #include "WebContentDetectionResult.h" |
| 39 #include "WebDateTimeChooserCompletion.h" | |
| 39 #include "WebDocument.h" | 40 #include "WebDocument.h" |
| 40 #include "WebElement.h" | 41 #include "WebElement.h" |
| 41 #include "WebFrame.h" | 42 #include "WebFrame.h" |
| 42 #include "WebFrameClient.h" | 43 #include "WebFrameClient.h" |
| 43 #include "WebFrameImpl.h" | 44 #include "WebFrameImpl.h" |
| 44 #include "WebHelperPluginImpl.h" | 45 #include "WebHelperPluginImpl.h" |
| 45 #include "WebHitTestResult.h" | 46 #include "WebHitTestResult.h" |
| 46 #include "WebInputEvent.h" | 47 #include "WebInputEvent.h" |
| 47 #include "WebSettings.h" | 48 #include "WebSettings.h" |
| 48 #include "WebViewClient.h" | 49 #include "WebViewClient.h" |
| 49 #include "WebViewImpl.h" | 50 #include "WebViewImpl.h" |
| 50 #include "WebWidget.h" | 51 #include "WebWidget.h" |
| 51 #include "core/dom/Document.h" | 52 #include "core/dom/Document.h" |
| 52 #include "core/dom/Element.h" | 53 #include "core/dom/Element.h" |
| 53 #include "core/html/HTMLDocument.h" | 54 #include "core/html/HTMLDocument.h" |
| 55 #include "core/html/HTMLInputElement.h" | |
| 54 #include "core/loader/FrameLoadRequest.h" | 56 #include "core/loader/FrameLoadRequest.h" |
| 55 #include "core/frame/FrameView.h" | 57 #include "core/frame/FrameView.h" |
| 58 #include "core/page/Chrome.h" | |
| 56 #include "core/page/Settings.h" | 59 #include "core/page/Settings.h" |
| 60 #include "core/platform/chromium/KeyboardCodes.h" | |
| 61 #include "core/testing/MockPagePopupDriver.h" | |
| 57 #include "public/platform/Platform.h" | 62 #include "public/platform/Platform.h" |
| 58 #include "public/platform/WebSize.h" | 63 #include "public/platform/WebSize.h" |
| 59 #include "public/platform/WebThread.h" | 64 #include "public/platform/WebThread.h" |
| 60 #include "public/platform/WebUnitTestSupport.h" | 65 #include "public/platform/WebUnitTestSupport.h" |
| 61 #include "public/web/WebWidgetClient.h" | 66 #include "public/web/WebWidgetClient.h" |
| 62 | 67 |
| 63 using namespace blink; | 68 using namespace blink; |
| 64 using blink::FrameTestHelpers::runPendingTasks; | 69 using blink::FrameTestHelpers::runPendingTasks; |
| 65 using blink::URLTestHelpers::toKURL; | 70 using blink::URLTestHelpers::toKURL; |
| 66 | 71 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 174 { | 179 { |
| 175 } | 180 } |
| 176 | 181 |
| 177 void setWebFrameClient(WebFrameClient* client) { m_webFrameClient = client; } | 182 void setWebFrameClient(WebFrameClient* client) { m_webFrameClient = client; } |
| 178 | 183 |
| 179 private: | 184 private: |
| 180 WebWidget* m_helperPluginWebWidget; | 185 WebWidget* m_helperPluginWebWidget; |
| 181 WebFrameClient* m_webFrameClient; | 186 WebFrameClient* m_webFrameClient; |
| 182 }; | 187 }; |
| 183 | 188 |
| 189 class DateTimeChooserWebViewClient : public WebViewClient { | |
| 190 public: | |
| 191 WebDateTimeChooserCompletion* chooserCompletion() | |
| 192 { | |
| 193 return m_chooserCompletion; | |
| 194 } | |
| 195 | |
| 196 void clearChooserCompletion() | |
| 197 { | |
| 198 m_chooserCompletion = 0; | |
| 199 } | |
| 200 | |
| 201 // WebViewClient methods | |
| 202 virtual bool openDateTimeChooser(const WebDateTimeChooserParams&, WebDateTim eChooserCompletion* chooser_completion) OVERRIDE | |
| 203 { | |
| 204 m_chooserCompletion = chooser_completion; | |
| 205 return true; | |
| 206 } | |
| 207 | |
| 208 private: | |
| 209 WebDateTimeChooserCompletion* m_chooserCompletion; | |
| 210 | |
| 211 }; | |
| 212 | |
| 184 class WebViewTest : public testing::Test { | 213 class WebViewTest : public testing::Test { |
| 185 public: | 214 public: |
| 186 WebViewTest() | 215 WebViewTest() |
| 187 : m_baseURL("http://www.test.com/") | 216 : m_baseURL("http://www.test.com/") |
| 188 { | 217 { |
| 189 } | 218 } |
| 190 | 219 |
| 191 virtual void TearDown() | 220 virtual void TearDown() |
| 192 { | 221 { |
| 193 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); | 222 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); |
| (...skipping 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1230 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "domfocusou t_domfocusin_events.html", true, 0); | 1259 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "domfocusou t_domfocusin_events.html", true, 0); |
| 1231 | 1260 |
| 1232 webView->setFocus(true); | 1261 webView->setFocus(true); |
| 1233 webView->setFocus(false); | 1262 webView->setFocus(false); |
| 1234 webView->setFocus(true); | 1263 webView->setFocus(true); |
| 1235 | 1264 |
| 1236 WebElement element = webView->mainFrame()->document().getElementById("messag e"); | 1265 WebElement element = webView->mainFrame()->document().getElementById("messag e"); |
| 1237 EXPECT_STREQ("DOMFocusOutDOMFocusIn", element.innerText().utf8().data()); | 1266 EXPECT_STREQ("DOMFocusOutDOMFocusIn", element.innerText().utf8().data()); |
| 1238 } | 1267 } |
| 1239 | 1268 |
| 1269 #if !ENABLE(INPUT_MULTIPLE_FIELDS_UI) | |
| 1270 static bool openDateTimeChooser(WebView* webView, WebCore::HTMLInputElement* inp utElement) | |
|
tkent
2013/11/21 00:09:43
The return value is not used. It should be void.
keishi
2013/11/21 15:07:12
Done.
| |
| 1271 { | |
| 1272 inputElement->focus(); | |
| 1273 | |
| 1274 WebKeyboardEvent keyEvent; | |
| 1275 keyEvent.windowsKeyCode = WebCore::VKEY_SPACE; | |
| 1276 keyEvent.type = WebInputEvent::RawKeyDown; | |
| 1277 keyEvent.setKeyIdentifierFromWindowsKeyCode(); | |
| 1278 webView->handleInputEvent(keyEvent); | |
| 1279 | |
| 1280 keyEvent.type = WebInputEvent::KeyUp; | |
| 1281 webView->handleInputEvent(keyEvent); | |
| 1282 return true; | |
| 1240 } | 1283 } |
| 1284 | |
| 1285 TEST_F(WebViewTest, ChooseValueFromDateTimeChooser) | |
| 1286 { | |
| 1287 DateTimeChooserWebViewClient client; | |
| 1288 std::string url = m_baseURL + "date_time_chooser.html"; | |
| 1289 URLTestHelpers::registerMockedURLLoad(toKURL(url), "date_time_chooser.html") ; | |
| 1290 WebViewImpl* webViewImpl = toWebViewImpl(m_webViewHelper.initializeAndLoad(u rl, true, 0, &client)); | |
| 1291 | |
| 1292 WebCore::Document* document = webViewImpl->mainFrameImpl()->frame()->documen t(); | |
| 1293 WebCore::Page* page = document->page(); | |
| 1294 OwnPtr<WebCore::MockPagePopupDriver> mockPagePopupDriver = WebCore::MockPage PopupDriver::create(page->mainFrame()); | |
| 1295 page->chrome().client().setPagePopupDriver(mockPagePopupDriver.get()); | |
|
tkent
2013/11/21 00:09:43
Is MockPagePopupDriver needed though it's for Andr
keishi
2013/11/21 15:07:12
This was left over from my efforts to run this tes
| |
| 1296 | |
| 1297 WebCore::HTMLInputElement* inputElement; | |
| 1298 | |
| 1299 inputElement = toHTMLInputElement(document->getElementById("date")); | |
| 1300 openDateTimeChooser(webViewImpl, inputElement); | |
| 1301 client.chooserCompletion()->didChooseValue(0); | |
| 1302 client.clearChooserCompletion(); | |
| 1303 EXPECT_STREQ("1970-01-01", inputElement->value().utf8().data()); | |
| 1304 | |
| 1305 openDateTimeChooser(webViewImpl, inputElement); | |
| 1306 client.chooserCompletion()->didChooseValue(std::numeric_limits<double>::quie t_NaN()); | |
| 1307 client.clearChooserCompletion(); | |
| 1308 EXPECT_STREQ("", inputElement->value().utf8().data()); | |
| 1309 | |
| 1310 inputElement = toHTMLInputElement(document->getElementById("datetimelocal")) ; | |
| 1311 openDateTimeChooser(webViewImpl, inputElement); | |
| 1312 client.chooserCompletion()->didChooseValue(0); | |
| 1313 client.clearChooserCompletion(); | |
| 1314 EXPECT_STREQ("1970-01-01T00:00", inputElement->value().utf8().data()); | |
| 1315 | |
| 1316 openDateTimeChooser(webViewImpl, inputElement); | |
| 1317 client.chooserCompletion()->didChooseValue(std::numeric_limits<double>::quie t_NaN()); | |
| 1318 client.clearChooserCompletion(); | |
| 1319 EXPECT_STREQ("", inputElement->value().utf8().data()); | |
| 1320 | |
| 1321 inputElement = toHTMLInputElement(document->getElementById("month")); | |
| 1322 openDateTimeChooser(webViewImpl, inputElement); | |
| 1323 client.chooserCompletion()->didChooseValue(0); | |
| 1324 client.clearChooserCompletion(); | |
| 1325 EXPECT_STREQ("1970-01", inputElement->value().utf8().data()); | |
| 1326 | |
| 1327 openDateTimeChooser(webViewImpl, inputElement); | |
| 1328 client.chooserCompletion()->didChooseValue(std::numeric_limits<double>::quie t_NaN()); | |
| 1329 client.clearChooserCompletion(); | |
| 1330 EXPECT_STREQ("", inputElement->value().utf8().data()); | |
| 1331 | |
| 1332 inputElement = toHTMLInputElement(document->getElementById("time")); | |
| 1333 openDateTimeChooser(webViewImpl, inputElement); | |
| 1334 client.chooserCompletion()->didChooseValue(0); | |
| 1335 client.clearChooserCompletion(); | |
| 1336 EXPECT_STREQ("00:00", inputElement->value().utf8().data()); | |
| 1337 | |
| 1338 openDateTimeChooser(webViewImpl, inputElement); | |
| 1339 client.chooserCompletion()->didChooseValue(std::numeric_limits<double>::quie t_NaN()); | |
| 1340 client.clearChooserCompletion(); | |
| 1341 EXPECT_STREQ("", inputElement->value().utf8().data()); | |
| 1342 | |
| 1343 inputElement = toHTMLInputElement(document->getElementById("week")); | |
| 1344 openDateTimeChooser(webViewImpl, inputElement); | |
| 1345 client.chooserCompletion()->didChooseValue(0); | |
| 1346 client.clearChooserCompletion(); | |
| 1347 EXPECT_STREQ("1970-W01", inputElement->value().utf8().data()); | |
| 1348 | |
| 1349 openDateTimeChooser(webViewImpl, inputElement); | |
| 1350 client.chooserCompletion()->didChooseValue(std::numeric_limits<double>::quie t_NaN()); | |
| 1351 client.clearChooserCompletion(); | |
| 1352 EXPECT_STREQ("", inputElement->value().utf8().data()); | |
| 1353 } | |
| 1354 #endif | |
| 1355 | |
| 1356 } | |
| OLD | NEW |