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

Unified Diff: chrome/browser/accessibility/browser_accessibility_win_unittest.cc

Issue 8770021: Initial implementation of IAccessible2 scrollTo and setTextSelection and (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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
Index: chrome/browser/accessibility/browser_accessibility_win_unittest.cc
===================================================================
--- chrome/browser/accessibility/browser_accessibility_win_unittest.cc (revision 112482)
+++ chrome/browser/accessibility/browser_accessibility_win_unittest.cc (working copy)
@@ -365,3 +365,36 @@
delete manager;
ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_);
}
+
+TEST_F(BrowserAccessibilityTest, TestScrollingLogic) {
+ #define SCROLL BrowserAccessibility::ComputeBestScrollOffset
+
+ // Test some cases where the focus is already within the viewport.
+ EXPECT_EQ(0, SCROLL(0, 25, 75, 25, 75, 0, 100));
+ EXPECT_EQ(100, SCROLL(100, 125, 175, 125, 175, 0, 100));
+ EXPECT_EQ(105, SCROLL(105, 125, 175, 125, 175, 0, 100));
+ EXPECT_EQ(125, SCROLL(125, 125, 175, 125, 175, 0, 100));
David Tseng 2011/12/02 00:33:04 Just for kicks, throw in a subfocus not equal to f
dmazzoni 2011/12/03 00:37:10 Done.
+ EXPECT_EQ(75, SCROLL(75, 125, 175, 125, 175, 0, 100));
David Tseng 2011/12/02 00:33:04 Curious, do we handle negative scrolling? (i.e. if
dmazzoni 2011/12/03 00:37:10 This function will return a negative value, sure.
+
+ // Test some cases where the focus needs to be scrolled to fit.
+ EXPECT_EQ(75, SCROLL(74, 125, 175, 125, 175, 0, 100));
+ EXPECT_EQ(75, SCROLL(50, 125, 175, 125, 175, 0, 100));
+ EXPECT_EQ(75, SCROLL(0, 125, 175, 125, 175, 0, 100));
+ EXPECT_EQ(125, SCROLL(126, 125, 175, 125, 175, 0, 100));
+ EXPECT_EQ(125, SCROLL(150, 125, 175, 125, 175, 0, 100));
+ EXPECT_EQ(125, SCROLL(200, 125, 175, 125, 175, 0, 100));
+
+ // Test some cases where the focus doesn't fit, so the subfocus is used.
+ EXPECT_EQ(125, SCROLL(0, 125, 130, 125, 175, 0, 25));
+ EXPECT_EQ(140, SCROLL(0, 140, 145, 125, 175, 0, 25));
+ EXPECT_EQ(150, SCROLL(0, 170, 175, 125, 175, 0, 25));
David Tseng 2011/12/02 00:33:04 How about adding a case for nonzero initial offset
dmazzoni 2011/12/03 00:37:10 Done.
+
+ // Test some cases where the viewport is a single point - which can be
+ // used to force an object to be scrolled to a specific location.
+ EXPECT_EQ(50, SCROLL(0, 125, 175, 125, 175, 75, 75));
+ EXPECT_EQ(25, SCROLL(0, 125, 175, 125, 175, 100, 100));
+ EXPECT_EQ(0, SCROLL(0, 125, 175, 125, 175, 125, 125));
+
+ #undef SCROLL
+}
+

Powered by Google App Engine
This is Rietveld 408576698