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

Unified Diff: Source/web/tests/TextFinderTest.cpp

Issue 1231673007: Don't zoom in TextFinder if autosizing is disabled (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: removed frame() helper from test Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/web/TextFinder.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/tests/TextFinderTest.cpp
diff --git a/Source/web/tests/TextFinderTest.cpp b/Source/web/tests/TextFinderTest.cpp
index dd863774c9d67024269ad69b756d0a4766649755..24b1a51e62b78d9892d30e447d462ddd65e50ee7 100644
--- a/Source/web/tests/TextFinderTest.cpp
+++ b/Source/web/tests/TextFinderTest.cpp
@@ -10,7 +10,10 @@
#include "core/dom/NodeList.h"
#include "core/dom/Range.h"
#include "core/dom/shadow/ShadowRoot.h"
+#include "core/frame/FrameHost.h"
#include "core/html/HTMLElement.h"
+#include "core/layout/TextAutosizer.h"
+#include "core/page/Page.h"
#include "platform/testing/UnitTestHelpers.h"
#include "public/platform/Platform.h"
#include "public/web/WebDocument.h"
@@ -134,6 +137,40 @@ TEST_F(TextFinderTest, FindTextSimple)
EXPECT_EQ(20, activeMatch->endOffset());
}
+TEST_F(TextFinderTest, FindTextAutosizing)
+{
+ document().body()->setInnerHTML("XXXXFindMeYYYYfindmeZZZZ", ASSERT_NO_EXCEPTION);
+
+ int identifier = 0;
+ WebString searchText(String("FindMe"));
+ WebFindOptions findOptions; // Default.
+ bool wrapWithinFrame = true;
+ WebRect* selectionRect = nullptr;
+
+ // Set viewport scale to 20 in order to simulate zoom-in
+ PinchViewport& pinchViewport = document().page()->frameHost().pinchViewport();
+ pinchViewport.setScale(20);
+
+ // Enforce autosizing
+ document().settings()->setTextAutosizingEnabled(true);
+ document().settings()->setTextAutosizingWindowSizeOverride(IntSize(20, 20));
+ document().textAutosizer()->updatePageInfo();
+
+ // In case of autosizing, scale _should_ change
+ ASSERT_TRUE(textFinder().find(identifier, searchText, findOptions, wrapWithinFrame, selectionRect));
+ ASSERT_TRUE(textFinder().activeMatch());
+ ASSERT_EQ(1, pinchViewport.scale()); // in this case to 1
+
+ // Disable autosizing and reset scale to 20
+ pinchViewport.setScale(20);
+ document().settings()->setTextAutosizingEnabled(false);
+ document().textAutosizer()->updatePageInfo();
+
+ ASSERT_TRUE(textFinder().find(identifier, searchText, findOptions, wrapWithinFrame, selectionRect));
+ ASSERT_TRUE(textFinder().activeMatch());
+ ASSERT_EQ(20, pinchViewport.scale());
+}
+
TEST_F(TextFinderTest, FindTextNotFound)
{
document().body()->setInnerHTML("XXXXFindMeYYYYfindmeZZZZ", ASSERT_NO_EXCEPTION);
« no previous file with comments | « Source/web/TextFinder.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698