summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/bookmark_manager_controller_unittest.mm
diff options
context:
space:
mode:
authorsnej@chromium.org <snej@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-28 21:46:40 +0000
committersnej@chromium.org <snej@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-28 21:46:40 +0000
commita359ecc79d700a0d40701a29d9f1ca226136cc21 (patch)
treed837bb1ab84005eeca930d33ef3c71b19e65ab51 /chrome/browser/cocoa/bookmark_manager_controller_unittest.mm
parent8692c5162c9e924f2f5cad18276180d4f6e22f89 (diff)
downloadchromium_src-a359ecc79d700a0d40701a29d9f1ca226136cc21.zip
chromium_src-a359ecc79d700a0d40701a29d9f1ca226136cc21.tar.gz
chromium_src-a359ecc79d700a0d40701a29d9f1ca226136cc21.tar.bz2
Mac bookmark mgr: Restore previously selected group when search field is cleared.
BUG=32734 TEST=none Review URL: http://codereview.chromium.org/555112 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37444 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/bookmark_manager_controller_unittest.mm')
-rw-r--r--chrome/browser/cocoa/bookmark_manager_controller_unittest.mm38
1 files changed, 38 insertions, 0 deletions
diff --git a/chrome/browser/cocoa/bookmark_manager_controller_unittest.mm b/chrome/browser/cocoa/bookmark_manager_controller_unittest.mm
index 50c2357..5f5c4cb 100644
--- a/chrome/browser/cocoa/bookmark_manager_controller_unittest.mm
+++ b/chrome/browser/cocoa/bookmark_manager_controller_unittest.mm
@@ -42,6 +42,11 @@ class BookmarkManagerControllerTest : public CocoaTest {
nil];
}
+ bool SearchResultsVisible() {
+ NSOutlineView* outline = [[controller_ groupsController] outline];
+ return [outline rowForItem:[controller_ searchGroup]] >= 0;
+ }
+
BrowserTestHelper browser_test_helper_;
BookmarkManagerController* controller_;
};
@@ -120,4 +125,37 @@ TEST_F(BookmarkManagerControllerTest, Search) {
EXPECT_EQ(0U, [shown count]);
}
+TEST_F(BookmarkManagerControllerTest, SearchSelection) {
+ BookmarkTreeController* groupsController = [controller_ groupsController];
+ AddFixtureItems();
+ BookmarkItem* originalSelection = [controller_ bookmarkBarItem];
+ EXPECT_FALSE(SearchResultsVisible());
+ EXPECT_EQ(originalSelection, [groupsController selectedItem]);
+
+ // Start a search and verify the search results group is selected.
+ [controller_ setSearchString:@"g"];
+ EXPECT_TRUE(SearchResultsVisible());
+ EXPECT_EQ([controller_ searchGroup], [groupsController selectedItem]);
+
+ // Type some more, see if updating the search string works.
+ [controller_ setSearchString:@"gmail"];
+ EXPECT_TRUE(SearchResultsVisible());
+ EXPECT_EQ([controller_ searchGroup], [groupsController selectedItem]);
+
+ // Clear search, verify search results are hidden and original sel restored.
+ [controller_ setSearchString:@""];
+ EXPECT_FALSE(SearchResultsVisible());
+ EXPECT_EQ(originalSelection, [groupsController selectedItem]);
+
+ // Now search, then change the selection, then clear search:
+ [controller_ setSearchString:@"gmail"];
+ EXPECT_TRUE(SearchResultsVisible());
+ EXPECT_EQ([controller_ searchGroup], [groupsController selectedItem]);
+ BookmarkItem* newerSelection = [controller_ otherBookmarksItem];
+ [controller_ showGroup:newerSelection];
+ [controller_ setSearchString:@""];
+ EXPECT_FALSE(SearchResultsVisible());
+ EXPECT_EQ(newerSelection, [groupsController selectedItem]);
+}
+
} // namespace