OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/callback.h" | 6 #include "base/callback.h" |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1181 // Do a delayed task to give the dialog time to exit. | 1181 // Do a delayed task to give the dialog time to exit. |
1182 base::MessageLoop::current()->PostTask( | 1182 base::MessageLoop::current()->PostTask( |
1183 FROM_HERE, CreateEventTask(this, &BookmarkBarViewTest12::Step7)); | 1183 FROM_HERE, CreateEventTask(this, &BookmarkBarViewTest12::Step7)); |
1184 } | 1184 } |
1185 | 1185 |
1186 void Step7() { | 1186 void Step7() { |
1187 Done(); | 1187 Done(); |
1188 } | 1188 } |
1189 }; | 1189 }; |
1190 | 1190 |
1191 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA) | 1191 VIEW_TEST(BookmarkBarViewTest12, CloseWithModalDialog) |
1192 // TODO(erg): linux_aura bringup: http://crbug.com/163931 | |
1193 #define MAYBE_CloseWithModalDialog DISABLED_CloseWithModalDialog | |
1194 #else | |
1195 #define MAYBE_CloseWithModalDialog CloseWithModalDialog | |
1196 #endif | |
1197 | |
1198 VIEW_TEST(BookmarkBarViewTest12, MAYBE_CloseWithModalDialog) | |
1199 | 1192 |
1200 // Tests clicking on the separator of a context menu (this is for coverage of | 1193 // Tests clicking on the separator of a context menu (this is for coverage of |
1201 // bug 17862). | 1194 // bug 17862). |
1202 class BookmarkBarViewTest13 : public BookmarkBarViewEventTestBase { | 1195 class BookmarkBarViewTest13 : public BookmarkBarViewEventTestBase { |
1203 public: | 1196 public: |
1204 BookmarkBarViewTest13() | 1197 BookmarkBarViewTest13() |
1205 : observer_(CreateEventTask(this, &BookmarkBarViewTest13::Step3)) { | 1198 : observer_(CreateEventTask(this, &BookmarkBarViewTest13::Step3)) { |
1206 } | 1199 } |
1207 | 1200 |
1208 protected: | 1201 protected: |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1831 EXPECT_TRUE(bb_view_->GetContextMenu() == NULL); | 1824 EXPECT_TRUE(bb_view_->GetContextMenu() == NULL); |
1832 EXPECT_TRUE(bb_view_->GetMenu() == NULL); | 1825 EXPECT_TRUE(bb_view_->GetMenu() == NULL); |
1833 | 1826 |
1834 Done(); | 1827 Done(); |
1835 } | 1828 } |
1836 | 1829 |
1837 BookmarkContextMenuNotificationObserver observer_; | 1830 BookmarkContextMenuNotificationObserver observer_; |
1838 }; | 1831 }; |
1839 | 1832 |
1840 VIEW_TEST(BookmarkBarViewTest21, ContextMenusForEmptyFolder) | 1833 VIEW_TEST(BookmarkBarViewTest21, ContextMenusForEmptyFolder) |
| 1834 |
| 1835 class BookmarkBarViewTest12_Step2 : public BookmarkBarViewEventTestBase { |
| 1836 protected: |
| 1837 virtual void DoTestOnMessageLoop() OVERRIDE { |
| 1838 // Open up the other folder. |
| 1839 views::TextButton* button = bb_view_->other_bookmarked_button(); |
| 1840 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
| 1841 ui_controls::DOWN | ui_controls::UP, |
| 1842 CreateEventTask(this, &BookmarkBarViewTest12_Step2::Step2)); |
| 1843 chrome::num_bookmark_urls_before_prompting = 1; |
| 1844 } |
| 1845 |
| 1846 virtual ~BookmarkBarViewTest12_Step2() { |
| 1847 chrome::num_bookmark_urls_before_prompting = 15; |
| 1848 } |
| 1849 |
| 1850 private: |
| 1851 void Step2() { |
| 1852 // Menu should be showing. |
| 1853 views::MenuItemView* menu = bb_view_->GetMenu(); |
| 1854 ASSERT_TRUE(menu != NULL); |
| 1855 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
| 1856 |
| 1857 views::MenuItemView* child_menu = |
| 1858 menu->GetSubmenu()->GetMenuItemAt(1); |
| 1859 ASSERT_TRUE(child_menu != NULL); |
| 1860 menu->GetMenuController()->CancelAll(); |
| 1861 Done(); |
| 1862 } |
| 1863 }; |
| 1864 |
| 1865 VIEW_TEST(BookmarkBarViewTest12_Step2, CloseWithModalDialog) |
| 1866 |
| 1867 class BookmarkBarViewTest12_Step3 : public BookmarkBarViewEventTestBase { |
| 1868 protected: |
| 1869 virtual void DoTestOnMessageLoop() OVERRIDE { |
| 1870 // Open up the other folder. |
| 1871 views::TextButton* button = bb_view_->other_bookmarked_button(); |
| 1872 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
| 1873 ui_controls::DOWN | ui_controls::UP, |
| 1874 CreateEventTask(this, &BookmarkBarViewTest12_Step3::Step2)); |
| 1875 chrome::num_bookmark_urls_before_prompting = 1; |
| 1876 } |
| 1877 |
| 1878 virtual ~BookmarkBarViewTest12_Step3() { |
| 1879 chrome::num_bookmark_urls_before_prompting = 15; |
| 1880 } |
| 1881 |
| 1882 private: |
| 1883 void Step2() { |
| 1884 // Menu should be showing. |
| 1885 views::MenuItemView* menu = bb_view_->GetMenu(); |
| 1886 ASSERT_TRUE(menu != NULL); |
| 1887 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
| 1888 |
| 1889 views::MenuItemView* child_menu = |
| 1890 menu->GetSubmenu()->GetMenuItemAt(1); |
| 1891 ASSERT_TRUE(child_menu != NULL); |
| 1892 |
| 1893 // Right click on the second child (a folder) to get its context menu. |
| 1894 ui_test_utils::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, |
| 1895 ui_controls::DOWN | ui_controls::UP, |
| 1896 CreateEventTask(this, &BookmarkBarViewTest12_Step3::Step3)); |
| 1897 } |
| 1898 |
| 1899 void Step3() { |
| 1900 // Make sure the context menu is showing. |
| 1901 views::MenuItemView* menu = bb_view_->GetContextMenu(); |
| 1902 ASSERT_TRUE(menu && menu->GetSubmenu() && menu->GetSubmenu()->IsShowing()); |
| 1903 |
| 1904 // Select the first item in the context menu (open all). |
| 1905 views::MenuItemView* child_menu = |
| 1906 menu->GetSubmenu()->GetMenuItemAt(0); |
| 1907 ASSERT_TRUE(child_menu != NULL); |
| 1908 ui_test_utils::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, |
| 1909 ui_controls::DOWN | ui_controls::UP, base::Closure()); |
| 1910 |
| 1911 menu->GetMenuController()->CancelAll(); |
| 1912 bb_view_->GetMenu()->GetMenuController()->CancelAll(); |
| 1913 Done(); |
| 1914 } |
| 1915 }; |
| 1916 |
| 1917 VIEW_TEST(BookmarkBarViewTest12_Step3, CloseWithModalDialog) |
OLD | NEW |