| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "app/theme_provider.h" | 7 #include "app/theme_provider.h" |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/scoped_nsobject.h" | 9 #include "base/scoped_nsobject.h" |
| 10 #include "base/string16.h" | 10 #include "base/string16.h" |
| (...skipping 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1308 [bar_ closeBookmarkFolder:nil]; | 1308 [bar_ closeBookmarkFolder:nil]; |
| 1309 } | 1309 } |
| 1310 | 1310 |
| 1311 // Verify that the folder menu presentation properly tracks mouse movements | 1311 // Verify that the folder menu presentation properly tracks mouse movements |
| 1312 // over the bar. Until there is a click no folder menus should show. After a | 1312 // over the bar. Until there is a click no folder menus should show. After a |
| 1313 // click on a folder folder menus should show until another click on a folder | 1313 // click on a folder folder menus should show until another click on a folder |
| 1314 // button, and a click outside the bar and its folder menus. | 1314 // button, and a click outside the bar and its folder menus. |
| 1315 TEST_F(BookmarkBarControllerTest, TestFolderButtons) { | 1315 TEST_F(BookmarkBarControllerTest, TestFolderButtons) { |
| 1316 BookmarkModel& model(*helper_.profile()->GetBookmarkModel()); | 1316 BookmarkModel& model(*helper_.profile()->GetBookmarkModel()); |
| 1317 const BookmarkNode* root = model.GetBookmarkBarNode(); | 1317 const BookmarkNode* root = model.GetBookmarkBarNode(); |
| 1318 const std::wstring model_string(L"1b 2f:[ 2f1b 2f2b ] 3b 4f:[ 4f1b 4f2b ] "); | 1318 const std::string model_string("1b 2f:[ 2f1b 2f2b ] 3b 4f:[ 4f1b 4f2b ] "); |
| 1319 model_test_utils::AddNodesFromModelString(model, root, model_string); | 1319 model_test_utils::AddNodesFromModelString(model, root, model_string); |
| 1320 | 1320 |
| 1321 // Validate initial model and that we do not have a folder controller. | 1321 // Validate initial model and that we do not have a folder controller. |
| 1322 std::wstring actualModelString = model_test_utils::ModelStringFromNode(root); | 1322 std::string actualModelString = model_test_utils::ModelStringFromNode(root); |
| 1323 EXPECT_EQ(model_string, actualModelString); | 1323 EXPECT_EQ(model_string, actualModelString); |
| 1324 EXPECT_FALSE([bar_ folderController]); | 1324 EXPECT_FALSE([bar_ folderController]); |
| 1325 | 1325 |
| 1326 // Add a real bookmark so we can click on it. | 1326 // Add a real bookmark so we can click on it. |
| 1327 const BookmarkNode* folder = root->GetChild(3); | 1327 const BookmarkNode* folder = root->GetChild(3); |
| 1328 model.AddURL(folder, folder->GetChildCount(), ASCIIToUTF16("CLICK ME"), | 1328 model.AddURL(folder, folder->GetChildCount(), ASCIIToUTF16("CLICK ME"), |
| 1329 GURL("http://www.google.com/")); | 1329 GURL("http://www.google.com/")); |
| 1330 | 1330 |
| 1331 // Click on a folder button. | 1331 // Click on a folder button. |
| 1332 BookmarkButton* button = [bar_ buttonWithTitleEqualTo:@"4f"]; | 1332 BookmarkButton* button = [bar_ buttonWithTitleEqualTo:@"4f"]; |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1595 EXPECT_TRUE([bar_ isAnimationRunning]); | 1595 EXPECT_TRUE([bar_ isAnimationRunning]); |
| 1596 | 1596 |
| 1597 // Now that we've closed the bookmark bar (with animation) the folder menu | 1597 // Now that we've closed the bookmark bar (with animation) the folder menu |
| 1598 // should have been closed thus releasing the folderController. | 1598 // should have been closed thus releasing the folderController. |
| 1599 EXPECT_FALSE([bar_ folderController]); | 1599 EXPECT_FALSE([bar_ folderController]); |
| 1600 } | 1600 } |
| 1601 | 1601 |
| 1602 TEST_F(BookmarkBarControllerTest, MoveRemoveAddButtons) { | 1602 TEST_F(BookmarkBarControllerTest, MoveRemoveAddButtons) { |
| 1603 BookmarkModel& model(*helper_.profile()->GetBookmarkModel()); | 1603 BookmarkModel& model(*helper_.profile()->GetBookmarkModel()); |
| 1604 const BookmarkNode* root = model.GetBookmarkBarNode(); | 1604 const BookmarkNode* root = model.GetBookmarkBarNode(); |
| 1605 const std::wstring model_string(L"1b 2f:[ 2f1b 2f2b ] 3b "); | 1605 const std::string model_string("1b 2f:[ 2f1b 2f2b ] 3b "); |
| 1606 model_test_utils::AddNodesFromModelString(model, root, model_string); | 1606 model_test_utils::AddNodesFromModelString(model, root, model_string); |
| 1607 | 1607 |
| 1608 // Validate initial model. | 1608 // Validate initial model. |
| 1609 std::wstring actualModelString = model_test_utils::ModelStringFromNode(root); | 1609 std::string actualModelString = model_test_utils::ModelStringFromNode(root); |
| 1610 EXPECT_EQ(model_string, actualModelString); | 1610 EXPECT_EQ(model_string, actualModelString); |
| 1611 | 1611 |
| 1612 // Remember how many buttons are showing. | 1612 // Remember how many buttons are showing. |
| 1613 int oldDisplayedButtons = [bar_ displayedButtonCount]; | 1613 int oldDisplayedButtons = [bar_ displayedButtonCount]; |
| 1614 NSArray* buttons = [bar_ buttons]; | 1614 NSArray* buttons = [bar_ buttons]; |
| 1615 | 1615 |
| 1616 // Move a button around a bit. | 1616 // Move a button around a bit. |
| 1617 [bar_ moveButtonFromIndex:0 toIndex:2]; | 1617 [bar_ moveButtonFromIndex:0 toIndex:2]; |
| 1618 EXPECT_NSEQ(@"2f", [[buttons objectAtIndex:0] title]); | 1618 EXPECT_NSEQ(@"2f", [[buttons objectAtIndex:0] title]); |
| 1619 EXPECT_NSEQ(@"3b", [[buttons objectAtIndex:1] title]); | 1619 EXPECT_NSEQ(@"3b", [[buttons objectAtIndex:1] title]); |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1847 initialWidth:NSWidth([parent_view_ frame]) | 1847 initialWidth:NSWidth([parent_view_ frame]) |
| 1848 delegate:nil | 1848 delegate:nil |
| 1849 resizeDelegate:resizeDelegate_.get()]); | 1849 resizeDelegate:resizeDelegate_.get()]); |
| 1850 InstallAndToggleBar(bar_.get()); | 1850 InstallAndToggleBar(bar_.get()); |
| 1851 } | 1851 } |
| 1852 }; | 1852 }; |
| 1853 | 1853 |
| 1854 TEST_F(BookmarkBarControllerDragDropTest, DragMoveBarBookmarkToOffTheSide) { | 1854 TEST_F(BookmarkBarControllerDragDropTest, DragMoveBarBookmarkToOffTheSide) { |
| 1855 BookmarkModel& model(*helper_.profile()->GetBookmarkModel()); | 1855 BookmarkModel& model(*helper_.profile()->GetBookmarkModel()); |
| 1856 const BookmarkNode* root = model.GetBookmarkBarNode(); | 1856 const BookmarkNode* root = model.GetBookmarkBarNode(); |
| 1857 const std::wstring model_string(L"1bWithLongName 2fWithLongName:[ " | 1857 const std::string model_string("1bWithLongName 2fWithLongName:[ " |
| 1858 "2f1bWithLongName 2f2fWithLongName:[ 2f2f1bWithLongName " | 1858 "2f1bWithLongName 2f2fWithLongName:[ 2f2f1bWithLongName " |
| 1859 "2f2f2bWithLongName 2f2f3bWithLongName 2f4b ] 2f3bWithLongName ] " | 1859 "2f2f2bWithLongName 2f2f3bWithLongName 2f4b ] 2f3bWithLongName ] " |
| 1860 "3bWithLongName 4bWithLongName 5bWithLongName 6bWithLongName " | 1860 "3bWithLongName 4bWithLongName 5bWithLongName 6bWithLongName " |
| 1861 "7bWithLongName 8bWithLongName 9bWithLongName 10bWithLongName " | 1861 "7bWithLongName 8bWithLongName 9bWithLongName 10bWithLongName " |
| 1862 "11bWithLongName 12bWithLongName 13b "); | 1862 "11bWithLongName 12bWithLongName 13b "); |
| 1863 model_test_utils::AddNodesFromModelString(model, root, model_string); | 1863 model_test_utils::AddNodesFromModelString(model, root, model_string); |
| 1864 | 1864 |
| 1865 // Validate initial model. | 1865 // Validate initial model. |
| 1866 std::wstring actualModelString = model_test_utils::ModelStringFromNode(root); | 1866 std::string actualModelString = model_test_utils::ModelStringFromNode(root); |
| 1867 EXPECT_EQ(model_string, actualModelString); | 1867 EXPECT_EQ(model_string, actualModelString); |
| 1868 | 1868 |
| 1869 // Insure that the off-the-side is not showing. | 1869 // Insure that the off-the-side is not showing. |
| 1870 ASSERT_FALSE([bar_ offTheSideButtonIsHidden]); | 1870 ASSERT_FALSE([bar_ offTheSideButtonIsHidden]); |
| 1871 | 1871 |
| 1872 // Remember how many buttons are showing and are available. | 1872 // Remember how many buttons are showing and are available. |
| 1873 int oldDisplayedButtons = [bar_ displayedButtonCount]; | 1873 int oldDisplayedButtons = [bar_ displayedButtonCount]; |
| 1874 int oldChildCount = root->GetChildCount(); | 1874 int oldChildCount = root->GetChildCount(); |
| 1875 | 1875 |
| 1876 // Pop up the off-the-side menu. | 1876 // Pop up the off-the-side menu. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1899 int newOTSCount = (int)[[otsController buttons] count]; | 1899 int newOTSCount = (int)[[otsController buttons] count]; |
| 1900 EXPECT_EQ(oldDisplayedButtons, newDisplayedButtons); | 1900 EXPECT_EQ(oldDisplayedButtons, newDisplayedButtons); |
| 1901 EXPECT_EQ(oldChildCount + 1, newChildCount); | 1901 EXPECT_EQ(oldChildCount + 1, newChildCount); |
| 1902 EXPECT_EQ(oldOTSCount + 1, newOTSCount); | 1902 EXPECT_EQ(oldOTSCount + 1, newOTSCount); |
| 1903 EXPECT_EQ(newOTSCount, newChildCount - newDisplayedButtons); | 1903 EXPECT_EQ(newOTSCount, newChildCount - newDisplayedButtons); |
| 1904 } | 1904 } |
| 1905 | 1905 |
| 1906 TEST_F(BookmarkBarControllerDragDropTest, DragBookmarkData) { | 1906 TEST_F(BookmarkBarControllerDragDropTest, DragBookmarkData) { |
| 1907 BookmarkModel& model(*helper_.profile()->GetBookmarkModel()); | 1907 BookmarkModel& model(*helper_.profile()->GetBookmarkModel()); |
| 1908 const BookmarkNode* root = model.GetBookmarkBarNode(); | 1908 const BookmarkNode* root = model.GetBookmarkBarNode(); |
| 1909 const std::wstring model_string(L"1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b 2f2f3b ] " | 1909 const std::string model_string("1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b 2f2f3b ] " |
| 1910 "2f3b ] 3b 4b "); | 1910 "2f3b ] 3b 4b "); |
| 1911 model_test_utils::AddNodesFromModelString(model, root, model_string); | 1911 model_test_utils::AddNodesFromModelString(model, root, model_string); |
| 1912 const BookmarkNode* other = model.other_node(); | 1912 const BookmarkNode* other = model.other_node(); |
| 1913 const std::wstring other_string(L"O1b O2b O3f:[ O3f1b O3f2f ] " | 1913 const std::string other_string("O1b O2b O3f:[ O3f1b O3f2f ] " |
| 1914 "O4f:[ O4f1b O4f2f ] 05b "); | 1914 "O4f:[ O4f1b O4f2f ] 05b "); |
| 1915 model_test_utils::AddNodesFromModelString(model, other, other_string); | 1915 model_test_utils::AddNodesFromModelString(model, other, other_string); |
| 1916 | 1916 |
| 1917 // Validate initial model. | 1917 // Validate initial model. |
| 1918 std::wstring actual = model_test_utils::ModelStringFromNode(root); | 1918 std::string actual = model_test_utils::ModelStringFromNode(root); |
| 1919 EXPECT_EQ(model_string, actual); | 1919 EXPECT_EQ(model_string, actual); |
| 1920 actual = model_test_utils::ModelStringFromNode(other); | 1920 actual = model_test_utils::ModelStringFromNode(other); |
| 1921 EXPECT_EQ(other_string, actual); | 1921 EXPECT_EQ(other_string, actual); |
| 1922 | 1922 |
| 1923 // Remember the little ones. | 1923 // Remember the little ones. |
| 1924 int oldChildCount = root->GetChildCount(); | 1924 int oldChildCount = root->GetChildCount(); |
| 1925 | 1925 |
| 1926 BookmarkButton* targetButton = [bar_ buttonWithTitleEqualTo:@"3b"]; | 1926 BookmarkButton* targetButton = [bar_ buttonWithTitleEqualTo:@"3b"]; |
| 1927 ASSERT_TRUE(targetButton); | 1927 ASSERT_TRUE(targetButton); |
| 1928 | 1928 |
| 1929 // Gen up some dragging data. | 1929 // Gen up some dragging data. |
| 1930 const BookmarkNode* newNode = other->GetChild(2); | 1930 const BookmarkNode* newNode = other->GetChild(2); |
| 1931 [bar_ setDragDataNode:newNode]; | 1931 [bar_ setDragDataNode:newNode]; |
| 1932 scoped_nsobject<FakeDragInfo> dragInfo([[FakeDragInfo alloc] init]); | 1932 scoped_nsobject<FakeDragInfo> dragInfo([[FakeDragInfo alloc] init]); |
| 1933 [dragInfo setDropLocation:[targetButton center]]; | 1933 [dragInfo setDropLocation:[targetButton center]]; |
| 1934 [bar_ dragBookmarkData:(id<NSDraggingInfo>)dragInfo.get()]; | 1934 [bar_ dragBookmarkData:(id<NSDraggingInfo>)dragInfo.get()]; |
| 1935 | 1935 |
| 1936 // There should one more button in the bar. | 1936 // There should one more button in the bar. |
| 1937 int newChildCount = root->GetChildCount(); | 1937 int newChildCount = root->GetChildCount(); |
| 1938 EXPECT_EQ(oldChildCount + 1, newChildCount); | 1938 EXPECT_EQ(oldChildCount + 1, newChildCount); |
| 1939 // Verify the model. | 1939 // Verify the model. |
| 1940 const std::wstring expected(L"1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b 2f2f3b ] " | 1940 const std::string expected("1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b 2f2f3b ] " |
| 1941 "2f3b ] O3f:[ O3f1b O3f2f ] 3b 4b "); | 1941 "2f3b ] O3f:[ O3f1b O3f2f ] 3b 4b "); |
| 1942 actual = model_test_utils::ModelStringFromNode(root); | 1942 actual = model_test_utils::ModelStringFromNode(root); |
| 1943 EXPECT_EQ(expected, actual); | 1943 EXPECT_EQ(expected, actual); |
| 1944 oldChildCount = newChildCount; | 1944 oldChildCount = newChildCount; |
| 1945 | 1945 |
| 1946 // Now do it over a folder button. | 1946 // Now do it over a folder button. |
| 1947 targetButton = [bar_ buttonWithTitleEqualTo:@"2f"]; | 1947 targetButton = [bar_ buttonWithTitleEqualTo:@"2f"]; |
| 1948 ASSERT_TRUE(targetButton); | 1948 ASSERT_TRUE(targetButton); |
| 1949 NSPoint targetPoint = [targetButton center]; | 1949 NSPoint targetPoint = [targetButton center]; |
| 1950 newNode = other->GetChild(2); // Should be O4f. | 1950 newNode = other->GetChild(2); // Should be O4f. |
| 1951 EXPECT_EQ(newNode->GetTitleAsString16(), ASCIIToUTF16("O4f")); | 1951 EXPECT_EQ(newNode->GetTitleAsString16(), ASCIIToUTF16("O4f")); |
| 1952 [bar_ setDragDataNode:newNode]; | 1952 [bar_ setDragDataNode:newNode]; |
| 1953 [dragInfo setDropLocation:targetPoint]; | 1953 [dragInfo setDropLocation:targetPoint]; |
| 1954 [bar_ dragBookmarkData:(id<NSDraggingInfo>)dragInfo.get()]; | 1954 [bar_ dragBookmarkData:(id<NSDraggingInfo>)dragInfo.get()]; |
| 1955 | 1955 |
| 1956 newChildCount = root->GetChildCount(); | 1956 newChildCount = root->GetChildCount(); |
| 1957 EXPECT_EQ(oldChildCount, newChildCount); | 1957 EXPECT_EQ(oldChildCount, newChildCount); |
| 1958 // Verify the model. | 1958 // Verify the model. |
| 1959 const std::wstring expected1(L"1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b 2f2f3b ] " | 1959 const std::string expected1("1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b 2f2f3b ] " |
| 1960 "2f3b O4f:[ O4f1b O4f2f ] ] O3f:[ O3f1b O3f2f ] " | 1960 "2f3b O4f:[ O4f1b O4f2f ] ] O3f:[ O3f1b O3f2f ] " |
| 1961 "3b 4b "); | 1961 "3b 4b "); |
| 1962 actual = model_test_utils::ModelStringFromNode(root); | 1962 actual = model_test_utils::ModelStringFromNode(root); |
| 1963 EXPECT_EQ(expected1, actual); | 1963 EXPECT_EQ(expected1, actual); |
| 1964 } | 1964 } |
| 1965 | 1965 |
| 1966 TEST_F(BookmarkBarControllerDragDropTest, AddURLs) { | 1966 TEST_F(BookmarkBarControllerDragDropTest, AddURLs) { |
| 1967 BookmarkModel& model(*helper_.profile()->GetBookmarkModel()); | 1967 BookmarkModel& model(*helper_.profile()->GetBookmarkModel()); |
| 1968 const BookmarkNode* root = model.GetBookmarkBarNode(); | 1968 const BookmarkNode* root = model.GetBookmarkBarNode(); |
| 1969 const std::wstring model_string(L"1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b 2f2f3b ] " | 1969 const std::string model_string("1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b 2f2f3b ] " |
| 1970 "2f3b ] 3b 4b "); | 1970 "2f3b ] 3b 4b "); |
| 1971 model_test_utils::AddNodesFromModelString(model, root, model_string); | 1971 model_test_utils::AddNodesFromModelString(model, root, model_string); |
| 1972 | 1972 |
| 1973 // Validate initial model. | 1973 // Validate initial model. |
| 1974 std::wstring actual = model_test_utils::ModelStringFromNode(root); | 1974 std::string actual = model_test_utils::ModelStringFromNode(root); |
| 1975 EXPECT_EQ(model_string, actual); | 1975 EXPECT_EQ(model_string, actual); |
| 1976 | 1976 |
| 1977 // Remember the children. | 1977 // Remember the children. |
| 1978 int oldChildCount = root->GetChildCount(); | 1978 int oldChildCount = root->GetChildCount(); |
| 1979 | 1979 |
| 1980 BookmarkButton* targetButton = [bar_ buttonWithTitleEqualTo:@"3b"]; | 1980 BookmarkButton* targetButton = [bar_ buttonWithTitleEqualTo:@"3b"]; |
| 1981 ASSERT_TRUE(targetButton); | 1981 ASSERT_TRUE(targetButton); |
| 1982 | 1982 |
| 1983 NSArray* urls = [NSArray arrayWithObjects: @"http://www.a.com/", | 1983 NSArray* urls = [NSArray arrayWithObjects: @"http://www.a.com/", |
| 1984 @"http://www.b.com/", nil]; | 1984 @"http://www.b.com/", nil]; |
| 1985 NSArray* titles = [NSArray arrayWithObjects: @"SiteA", @"SiteB", nil]; | 1985 NSArray* titles = [NSArray arrayWithObjects: @"SiteA", @"SiteB", nil]; |
| 1986 [bar_ addURLs:urls withTitles:titles at:[targetButton center]]; | 1986 [bar_ addURLs:urls withTitles:titles at:[targetButton center]]; |
| 1987 | 1987 |
| 1988 // There should two more nodes in the bar. | 1988 // There should two more nodes in the bar. |
| 1989 int newChildCount = root->GetChildCount(); | 1989 int newChildCount = root->GetChildCount(); |
| 1990 EXPECT_EQ(oldChildCount + 2, newChildCount); | 1990 EXPECT_EQ(oldChildCount + 2, newChildCount); |
| 1991 // Verify the model. | 1991 // Verify the model. |
| 1992 const std::wstring expected(L"1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b 2f2f3b ] " | 1992 const std::string expected("1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b 2f2f3b ] " |
| 1993 "2f3b ] SiteA SiteB 3b 4b "); | 1993 "2f3b ] SiteA SiteB 3b 4b "); |
| 1994 actual = model_test_utils::ModelStringFromNode(root); | 1994 actual = model_test_utils::ModelStringFromNode(root); |
| 1995 EXPECT_EQ(expected, actual); | 1995 EXPECT_EQ(expected, actual); |
| 1996 } | 1996 } |
| 1997 | 1997 |
| 1998 TEST_F(BookmarkBarControllerDragDropTest, ControllerForNode) { | 1998 TEST_F(BookmarkBarControllerDragDropTest, ControllerForNode) { |
| 1999 BookmarkModel& model(*helper_.profile()->GetBookmarkModel()); | 1999 BookmarkModel& model(*helper_.profile()->GetBookmarkModel()); |
| 2000 const BookmarkNode* root = model.GetBookmarkBarNode(); | 2000 const BookmarkNode* root = model.GetBookmarkBarNode(); |
| 2001 const std::wstring model_string(L"1b 2f:[ 2f1b 2f2b ] 3b "); | 2001 const std::string model_string("1b 2f:[ 2f1b 2f2b ] 3b "); |
| 2002 model_test_utils::AddNodesFromModelString(model, root, model_string); | 2002 model_test_utils::AddNodesFromModelString(model, root, model_string); |
| 2003 | 2003 |
| 2004 // Validate initial model. | 2004 // Validate initial model. |
| 2005 std::wstring actualModelString = model_test_utils::ModelStringFromNode(root); | 2005 std::string actualModelString = model_test_utils::ModelStringFromNode(root); |
| 2006 EXPECT_EQ(model_string, actualModelString); | 2006 EXPECT_EQ(model_string, actualModelString); |
| 2007 | 2007 |
| 2008 // Find the main bar controller. | 2008 // Find the main bar controller. |
| 2009 const void* expectedController = bar_; | 2009 const void* expectedController = bar_; |
| 2010 const void* actualController = [bar_ controllerForNode:root]; | 2010 const void* actualController = [bar_ controllerForNode:root]; |
| 2011 EXPECT_EQ(expectedController, actualController); | 2011 EXPECT_EQ(expectedController, actualController); |
| 2012 } | 2012 } |
| 2013 | 2013 |
| 2014 TEST_F(BookmarkBarControllerDragDropTest, DropPositionIndicator) { | 2014 TEST_F(BookmarkBarControllerDragDropTest, DropPositionIndicator) { |
| 2015 BookmarkModel& model(*helper_.profile()->GetBookmarkModel()); | 2015 BookmarkModel& model(*helper_.profile()->GetBookmarkModel()); |
| 2016 const BookmarkNode* root = model.GetBookmarkBarNode(); | 2016 const BookmarkNode* root = model.GetBookmarkBarNode(); |
| 2017 const std::wstring model_string(L"1b 2f:[ 2f1b 2f2b 2f3b ] 3b 4b "); | 2017 const std::string model_string("1b 2f:[ 2f1b 2f2b 2f3b ] 3b 4b "); |
| 2018 model_test_utils::AddNodesFromModelString(model, root, model_string); | 2018 model_test_utils::AddNodesFromModelString(model, root, model_string); |
| 2019 | 2019 |
| 2020 // Validate initial model. | 2020 // Validate initial model. |
| 2021 std::wstring actualModel = model_test_utils::ModelStringFromNode(root); | 2021 std::string actualModel = model_test_utils::ModelStringFromNode(root); |
| 2022 EXPECT_EQ(model_string, actualModel); | 2022 EXPECT_EQ(model_string, actualModel); |
| 2023 | 2023 |
| 2024 // Test a series of points starting at the right edge of the bar. | 2024 // Test a series of points starting at the right edge of the bar. |
| 2025 BookmarkButton* targetButton = [bar_ buttonWithTitleEqualTo:@"1b"]; | 2025 BookmarkButton* targetButton = [bar_ buttonWithTitleEqualTo:@"1b"]; |
| 2026 ASSERT_TRUE(targetButton); | 2026 ASSERT_TRUE(targetButton); |
| 2027 NSPoint targetPoint = [targetButton left]; | 2027 NSPoint targetPoint = [targetButton left]; |
| 2028 const CGFloat xDelta = 0.5 * bookmarks::kBookmarkHorizontalPadding; | 2028 const CGFloat xDelta = 0.5 * bookmarks::kBookmarkHorizontalPadding; |
| 2029 const CGFloat baseOffset = targetPoint.x; | 2029 const CGFloat baseOffset = targetPoint.x; |
| 2030 CGFloat expected = xDelta; | 2030 CGFloat expected = xDelta; |
| 2031 CGFloat actual = [bar_ indicatorPosForDragToPoint:targetPoint]; | 2031 CGFloat actual = [bar_ indicatorPosForDragToPoint:targetPoint]; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2072 bookmark_button::kBookmarkPulseFlagKey, | 2072 bookmark_button::kBookmarkPulseFlagKey, |
| 2073 nil]; | 2073 nil]; |
| 2074 [[NSNotificationCenter defaultCenter] | 2074 [[NSNotificationCenter defaultCenter] |
| 2075 postNotificationName:bookmark_button::kPulseBookmarkButtonNotification | 2075 postNotificationName:bookmark_button::kPulseBookmarkButtonNotification |
| 2076 object:nil | 2076 object:nil |
| 2077 userInfo:dict]; | 2077 userInfo:dict]; |
| 2078 EXPECT_FALSE([button isContinuousPulsing]); | 2078 EXPECT_FALSE([button isContinuousPulsing]); |
| 2079 } | 2079 } |
| 2080 | 2080 |
| 2081 } // namespace | 2081 } // namespace |
| OLD | NEW |