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

Side by Side Diff: Source/web/tests/WebFrameTest.cpp

Issue 198683002: Make it possible to override the tickmarks for a WebFrame. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 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
« no previous file with comments | « Source/web/WebFrameImpl.cpp ('k') | public/web/WebFrame.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 3365 matching lines...) Expand 10 before | Expand all | Expand 10 after
3376 3376
3377 // The first scopeStringMatches will have reset the state. Detach before it actually scopes. 3377 // The first scopeStringMatches will have reset the state. Detach before it actually scopes.
3378 EXPECT_TRUE(mainFrame->document().getElementById("frame").remove()); 3378 EXPECT_TRUE(mainFrame->document().getElementById("frame").remove());
3379 3379
3380 runPendingTasks(); 3380 runPendingTasks();
3381 EXPECT_TRUE(client.findResultsAreReady()); 3381 EXPECT_TRUE(client.findResultsAreReady());
3382 3382
3383 holdSecondFrame.release(); 3383 holdSecondFrame.release();
3384 } 3384 }
3385 3385
3386 TEST_F(WebFrameTest, SetTickmarks)
3387 {
3388 registerMockedHttpURLLoad("find.html");
3389
3390 FindUpdateWebFrameClient client;
3391 FrameTestHelpers::WebViewHelper webViewHelper;
3392 webViewHelper.initializeAndLoad(m_baseURL + "find.html", true, &client);
3393 webViewHelper.webView()->resize(WebSize(640, 480));
3394 webViewHelper.webView()->layout();
3395 runPendingTasks();
3396
3397 static const char* kFindString = "foo";
3398 static const int kFindIdentifier = 12345;
3399
3400 WebFindOptions options;
3401 WebString searchText = WebString::fromUTF8(kFindString);
3402 WebFrameImpl* mainFrame = toWebFrameImpl(webViewHelper.webView()->mainFrame( ));
3403 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0)) ;
3404
3405 mainFrame->resetMatchCount();
3406 mainFrame->scopeStringMatches(kFindIdentifier, searchText, options, true);
3407
3408 runPendingTasks();
3409 EXPECT_TRUE(client.findResultsAreReady());
3410
3411 // Get the tickmarks for the original find request.
3412 WebCore::FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl() ->frameView();
3413 RefPtr<WebCore::Scrollbar> scrollbar = frameView->createScrollbar(WebCore::H orizontalScrollbar);
3414 Vector<WebCore::IntRect> originalTickmarks;
3415 scrollbar->getTickmarks(originalTickmarks);
3416 EXPECT_EQ(4u, originalTickmarks.size());
3417
3418 // Override the tickmarks.
3419 Vector<WebCore::IntRect> overridingTickmarksExpected;
3420 overridingTickmarksExpected.append(WebCore::IntRect(0, 0, 100, 100));
3421 overridingTickmarksExpected.append(WebCore::IntRect(0, 20, 100, 100));
3422 overridingTickmarksExpected.append(WebCore::IntRect(0, 30, 100, 100));
3423 mainFrame->setTickmarks(overridingTickmarksExpected);
3424
3425 // Check the tickmarks are overriden correctly.
3426 Vector<WebCore::IntRect> overridingTickmarksActual;
3427 scrollbar->getTickmarks(overridingTickmarksActual);
3428 EXPECT_EQ(overridingTickmarksExpected, overridingTickmarksActual);
3429
3430 // Reset the tickmark behavior.
3431 Vector<WebCore::IntRect> resetTickmarks;
3432 mainFrame->setTickmarks(resetTickmarks);
3433
3434 // Check that the original tickmarks are returned
3435 Vector<WebCore::IntRect> originalTickmarksAfterReset;
3436 scrollbar->getTickmarks(originalTickmarksAfterReset);
3437 EXPECT_EQ(originalTickmarks, originalTickmarksAfterReset);
3438 }
3439
3386 static WebPoint topLeft(const WebRect& rect) 3440 static WebPoint topLeft(const WebRect& rect)
3387 { 3441 {
3388 return WebPoint(rect.x, rect.y); 3442 return WebPoint(rect.x, rect.y);
3389 } 3443 }
3390 3444
3391 static WebPoint bottomRightMinusOne(const WebRect& rect) 3445 static WebPoint bottomRightMinusOne(const WebRect& rect)
3392 { 3446 {
3393 // FIXME: If we don't subtract 1 from the x- and y-coordinates of the 3447 // FIXME: If we don't subtract 1 from the x- and y-coordinates of the
3394 // selection bounds, selectRange() will select the *next* element. That's 3448 // selection bounds, selectRange() will select the *next* element. That's
3395 // strictly correct, as hit-testing checks the pixel to the lower-right of 3449 // strictly correct, as hit-testing checks the pixel to the lower-right of
(...skipping 1841 matching lines...) Expand 10 before | Expand all | Expand 10 after
5237 webViewHelper.initializeAndLoad("about:blank"); 5291 webViewHelper.initializeAndLoad("about:blank");
5238 5292
5239 WebCore::FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl() ->frameView(); 5293 WebCore::FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl() ->frameView();
5240 frameView->setFrameRect(WebCore::IntRect(0, 0, 200, 200)); 5294 frameView->setFrameRect(WebCore::IntRect(0, 0, 200, 200));
5241 EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 200, 200), frameView->frameRect()); 5295 EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 200, 200), frameView->frameRect());
5242 frameView->setFrameRect(WebCore::IntRect(100, 100, 200, 200)); 5296 frameView->setFrameRect(WebCore::IntRect(100, 100, 200, 200));
5243 EXPECT_EQ_RECT(WebCore::IntRect(100, 100, 200, 200), frameView->frameRect()) ; 5297 EXPECT_EQ_RECT(WebCore::IntRect(100, 100, 200, 200), frameView->frameRect()) ;
5244 } 5298 }
5245 5299
5246 } // namespace 5300 } // namespace
OLDNEW
« no previous file with comments | « Source/web/WebFrameImpl.cpp ('k') | public/web/WebFrame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698