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

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

Issue 1839643009: RELEASE_ASSERT -> CHECK and ASSERT -> DCHECK in web. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Return DCHECK_IS_ON checks. Created 4 years, 8 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) 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 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after
1435 WebURL m_scheduledIntentURL; 1435 WebURL m_scheduledIntentURL;
1436 bool m_wasInMainFrame; 1436 bool m_wasInMainFrame;
1437 WebContentDetectionResult m_contentDetectionResult; 1437 WebContentDetectionResult m_contentDetectionResult;
1438 }; 1438 };
1439 1439
1440 bool WebViewTest::tapElement(WebInputEvent::Type type, const RawPtr<Element>& el ement) 1440 bool WebViewTest::tapElement(WebInputEvent::Type type, const RawPtr<Element>& el ement)
1441 { 1441 {
1442 if (!element || !element->layoutObject()) 1442 if (!element || !element->layoutObject())
1443 return false; 1443 return false;
1444 1444
1445 ASSERT(m_webViewHelper.webView()); 1445 DCHECK(m_webViewHelper.webView());
1446 element->scrollIntoViewIfNeeded(); 1446 element->scrollIntoViewIfNeeded();
1447 1447
1448 // TODO(bokan): Technically incorrect, event positions should be in viewport space. crbug.com/371902. 1448 // TODO(bokan): Technically incorrect, event positions should be in viewport space. crbug.com/371902.
1449 IntPoint center = m_webViewHelper.webViewImpl()->mainFrameImpl()->frameView( )->contentsToScreen( 1449 IntPoint center = m_webViewHelper.webViewImpl()->mainFrameImpl()->frameView( )->contentsToScreen(
1450 element->layoutObject()->absoluteBoundingBoxRect()).center(); 1450 element->layoutObject()->absoluteBoundingBoxRect()).center();
1451 1451
1452 WebGestureEvent event; 1452 WebGestureEvent event;
1453 event.type = type; 1453 event.type = type;
1454 event.sourceDevice = WebGestureDeviceTouchscreen; 1454 event.sourceDevice = WebGestureDeviceTouchscreen;
1455 event.x = center.x(); 1455 event.x = center.x();
1456 event.y = center.y(); 1456 event.y = center.y();
1457 1457
1458 m_webViewHelper.webView()->handleInputEvent(event); 1458 m_webViewHelper.webView()->handleInputEvent(event);
1459 runPendingTasks(); 1459 runPendingTasks();
1460 return true; 1460 return true;
1461 } 1461 }
1462 1462
1463 bool WebViewTest::tapElementById(WebInputEvent::Type type, const WebString& id) 1463 bool WebViewTest::tapElementById(WebInputEvent::Type type, const WebString& id)
1464 { 1464 {
1465 ASSERT(m_webViewHelper.webView()); 1465 DCHECK(m_webViewHelper.webView());
1466 RawPtr<Element> element = static_cast<RawPtr<Element>>(m_webViewHelper.webVi ew()->mainFrame()->document().getElementById(id)); 1466 RawPtr<Element> element = static_cast<RawPtr<Element>>(m_webViewHelper.webVi ew()->mainFrame()->document().getElementById(id));
1467 return tapElement(type, element); 1467 return tapElement(type, element);
1468 } 1468 }
1469 1469
1470 TEST_F(WebViewTest, DetectContentAroundPosition) 1470 TEST_F(WebViewTest, DetectContentAroundPosition)
1471 { 1471 {
1472 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("content_listeners.html")); 1472 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("content_listeners.html"));
1473 1473
1474 ContentDetectorClient client; 1474 ContentDetectorClient client;
1475 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "content_li steners.html", true, 0, &client); 1475 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "content_li steners.html", true, 0, &client);
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after
2338 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false)); 2338 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false));
2339 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true)); 2339 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true));
2340 2340
2341 // Removing the final handler results in a no-handlers call. 2341 // Removing the final handler results in a no-handlers call.
2342 registry->didRemoveEventHandler(*document, touchEvent); 2342 registry->didRemoveEventHandler(*document, touchEvent);
2343 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(false)); 2343 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(false));
2344 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true)); 2344 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true));
2345 2345
2346 // Adding a handler on a div results in a has-handlers call. 2346 // Adding a handler on a div results in a has-handlers call.
2347 Element* parentDiv = document->getElementById("parentdiv"); 2347 Element* parentDiv = document->getElementById("parentdiv");
2348 ASSERT(parentDiv); 2348 DCHECK(parentDiv);
2349 registry->didAddEventHandler(*parentDiv, touchEvent); 2349 registry->didAddEventHandler(*parentDiv, touchEvent);
2350 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false)); 2350 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false));
2351 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(true)); 2351 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(true));
2352 2352
2353 // Adding a duplicate handler on the div, clearing all document handlers 2353 // Adding a duplicate handler on the div, clearing all document handlers
2354 // (of which there are none) and removing the extra handler on the div 2354 // (of which there are none) and removing the extra handler on the div
2355 // all have no effect. 2355 // all have no effect.
2356 registry->didAddEventHandler(*parentDiv, touchEvent); 2356 registry->didAddEventHandler(*parentDiv, touchEvent);
2357 registry->didRemoveAllEventHandlers(*document); 2357 registry->didRemoveAllEventHandlers(*document);
2358 registry->didRemoveEventHandler(*parentDiv, touchEvent); 2358 registry->didRemoveEventHandler(*parentDiv, touchEvent);
(...skipping 12 matching lines...) Expand all
2371 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(true)); 2371 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(true));
2372 registry->didAddEventHandler(*parentDiv, touchEvent); 2372 registry->didAddEventHandler(*parentDiv, touchEvent);
2373 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false)); 2373 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false));
2374 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true)); 2374 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true));
2375 registry->didRemoveAllEventHandlers(*parentDiv); 2375 registry->didRemoveAllEventHandlers(*parentDiv);
2376 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(false)); 2376 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(false));
2377 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true)); 2377 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true));
2378 2378
2379 // Adding a handler inside of a child iframe results in a has-handlers call. 2379 // Adding a handler inside of a child iframe results in a has-handlers call.
2380 Element* childFrame = document->getElementById("childframe"); 2380 Element* childFrame = document->getElementById("childframe");
2381 ASSERT(childFrame); 2381 DCHECK(childFrame);
2382 Document* childDocument = toHTMLIFrameElement(childFrame)->contentDocument() ; 2382 Document* childDocument = toHTMLIFrameElement(childFrame)->contentDocument() ;
2383 Element* childDiv = childDocument->getElementById("childdiv"); 2383 Element* childDiv = childDocument->getElementById("childdiv");
2384 ASSERT(childDiv); 2384 DCHECK(childDiv);
2385 registry->didAddEventHandler(*childDiv, touchEvent); 2385 registry->didAddEventHandler(*childDiv, touchEvent);
2386 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false)); 2386 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false));
2387 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(true)); 2387 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(true));
2388 2388
2389 // Adding and clearing handlers in the parent doc or elsewhere in the child doc 2389 // Adding and clearing handlers in the parent doc or elsewhere in the child doc
2390 // has no impact. 2390 // has no impact.
2391 registry->didAddEventHandler(*document, touchEvent); 2391 registry->didAddEventHandler(*document, touchEvent);
2392 registry->didAddEventHandler(*childFrame, touchEvent); 2392 registry->didAddEventHandler(*childFrame, touchEvent);
2393 registry->didAddEventHandler(*childDocument, touchEvent); 2393 registry->didAddEventHandler(*childDocument, touchEvent);
2394 registry->didRemoveAllEventHandlers(*document); 2394 registry->didRemoveAllEventHandlers(*document);
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
2712 { 2712 {
2713 std::string url = m_baseURL + "subtree-layout.html"; 2713 std::string url = m_baseURL + "subtree-layout.html";
2714 URLTestHelpers::registerMockedURLLoad(toKURL(url), "subtree-layout.html"); 2714 URLTestHelpers::registerMockedURLLoad(toKURL(url), "subtree-layout.html");
2715 WebView* webView = m_webViewHelper.initialize(true); 2715 WebView* webView = m_webViewHelper.initialize(true);
2716 2716
2717 webView->enableAutoResizeMode(WebSize(200, 200), WebSize(200, 200)); 2717 webView->enableAutoResizeMode(WebSize(200, 200), WebSize(200, 200));
2718 loadFrame(webView->mainFrame(), url); 2718 loadFrame(webView->mainFrame(), url);
2719 2719
2720 FrameView* frameView = m_webViewHelper.webViewImpl()->mainFrameImpl()->frame View(); 2720 FrameView* frameView = m_webViewHelper.webViewImpl()->mainFrameImpl()->frame View();
2721 2721
2722 // Auto-resizing used to ASSERT(needsLayout()) in LayoutBlockFlow::layout. T his EXPECT is 2722 // Auto-resizing used to DCHECK(needsLayout()) in LayoutBlockFlow::layout. T his EXPECT is
2723 // merely a dummy. The real test is that we don't trigger asserts in debug b uilds. 2723 // merely a dummy. The real test is that we don't trigger asserts in debug b uilds.
2724 EXPECT_FALSE(frameView->needsLayout()); 2724 EXPECT_FALSE(frameView->needsLayout());
2725 }; 2725 };
2726 2726
2727 TEST_F(WebViewTest, PreferredSize) 2727 TEST_F(WebViewTest, PreferredSize)
2728 { 2728 {
2729 std::string url = m_baseURL + "specify_size.html?100px:100px"; 2729 std::string url = m_baseURL + "specify_size.html?100px:100px";
2730 URLTestHelpers::registerMockedURLLoad(toKURL(url), "specify_size.html"); 2730 URLTestHelpers::registerMockedURLLoad(toKURL(url), "specify_size.html");
2731 WebView* webView = m_webViewHelper.initializeAndLoad(url, true); 2731 WebView* webView = m_webViewHelper.initializeAndLoad(url, true);
2732 2732
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
3245 frame->setAutofillClient(&client); 3245 frame->setAutofillClient(&client);
3246 webView->setInitialFocus(false); 3246 webView->setInitialFocus(false);
3247 3247
3248 EXPECT_TRUE(webView->confirmComposition(WebString::fromUTF8(std::string("hel lo").c_str()))); 3248 EXPECT_TRUE(webView->confirmComposition(WebString::fromUTF8(std::string("hel lo").c_str())));
3249 EXPECT_EQ(1, client.textChangesFromUserGesture()); 3249 EXPECT_EQ(1, client.textChangesFromUserGesture());
3250 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); 3250 EXPECT_FALSE(UserGestureIndicator::processingUserGesture());
3251 frame->setAutofillClient(0); 3251 frame->setAutofillClient(0);
3252 } 3252 }
3253 3253
3254 } // namespace blink 3254 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698