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/location.h" | 8 #include "base/location.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 } | 362 } |
363 | 363 |
364 views::LabelButton* GetBookmarkButton(int view_index) { | 364 views::LabelButton* GetBookmarkButton(int view_index) { |
365 return bb_view_->GetBookmarkButton(view_index); | 365 return bb_view_->GetBookmarkButton(view_index); |
366 } | 366 } |
367 | 367 |
368 // See comment above class description for what this does. | 368 // See comment above class description for what this does. |
369 virtual bool CreateBigMenu() { return false; } | 369 virtual bool CreateBigMenu() { return false; } |
370 | 370 |
371 BookmarkModel* model_; | 371 BookmarkModel* model_; |
372 scoped_ptr<BookmarkBarView> bb_view_; | 372 std::unique_ptr<BookmarkBarView> bb_view_; |
373 TestingPageNavigator navigator_; | 373 TestingPageNavigator navigator_; |
374 | 374 |
375 private: | 375 private: |
376 void AddTestData(bool big_menu) { | 376 void AddTestData(bool big_menu) { |
377 const BookmarkNode* bb_node = model_->bookmark_bar_node(); | 377 const BookmarkNode* bb_node = model_->bookmark_bar_node(); |
378 std::string test_base = "file:///c:/tmp/"; | 378 std::string test_base = "file:///c:/tmp/"; |
379 const BookmarkNode* f1 = model_->AddFolder(bb_node, 0, ASCIIToUTF16("F1")); | 379 const BookmarkNode* f1 = model_->AddFolder(bb_node, 0, ASCIIToUTF16("F1")); |
380 model_->AddURL(f1, 0, ASCIIToUTF16("f1a"), GURL(test_base + "f1a")); | 380 model_->AddURL(f1, 0, ASCIIToUTF16("f1a"), GURL(test_base + "f1a")); |
381 const BookmarkNode* f11 = model_->AddFolder(f1, 1, ASCIIToUTF16("F11")); | 381 const BookmarkNode* f11 = model_->AddFolder(f1, 1, ASCIIToUTF16("F11")); |
382 model_->AddURL(f11, 0, ASCIIToUTF16("f11a"), GURL(test_base + "f11a")); | 382 model_->AddURL(f11, 0, ASCIIToUTF16("f11a"), GURL(test_base + "f11a")); |
(...skipping 16 matching lines...) Expand all Loading... |
399 const BookmarkNode* of = model_->AddFolder(model_->other_node(), 1, | 399 const BookmarkNode* of = model_->AddFolder(model_->other_node(), 1, |
400 ASCIIToUTF16("OF")); | 400 ASCIIToUTF16("OF")); |
401 model_->AddURL(of, 0, ASCIIToUTF16("ofa"), GURL(test_base + "ofa")); | 401 model_->AddURL(of, 0, ASCIIToUTF16("ofa"), GURL(test_base + "ofa")); |
402 model_->AddURL(of, 1, ASCIIToUTF16("ofb"), GURL(test_base + "ofb")); | 402 model_->AddURL(of, 1, ASCIIToUTF16("ofb"), GURL(test_base + "ofb")); |
403 const BookmarkNode* of2 = model_->AddFolder(model_->other_node(), 2, | 403 const BookmarkNode* of2 = model_->AddFolder(model_->other_node(), 2, |
404 ASCIIToUTF16("OF2")); | 404 ASCIIToUTF16("OF2")); |
405 model_->AddURL(of2, 0, ASCIIToUTF16("of2a"), GURL(test_base + "of2a")); | 405 model_->AddURL(of2, 0, ASCIIToUTF16("of2a"), GURL(test_base + "of2a")); |
406 model_->AddURL(of2, 1, ASCIIToUTF16("of2b"), GURL(test_base + "of2b")); | 406 model_->AddURL(of2, 1, ASCIIToUTF16("of2b"), GURL(test_base + "of2b")); |
407 } | 407 } |
408 | 408 |
409 scoped_ptr<ChromeContentClient> content_client_; | 409 std::unique_ptr<ChromeContentClient> content_client_; |
410 scoped_ptr<ChromeContentBrowserClient> browser_content_client_; | 410 std::unique_ptr<ChromeContentBrowserClient> browser_content_client_; |
411 scoped_ptr<TestingProfile> profile_; | 411 std::unique_ptr<TestingProfile> profile_; |
412 scoped_ptr<Browser> browser_; | 412 std::unique_ptr<Browser> browser_; |
413 scoped_ptr<ScopedTestingLocalState> local_state_; | 413 std::unique_ptr<ScopedTestingLocalState> local_state_; |
414 }; | 414 }; |
415 | 415 |
416 // Clicks on first menu, makes sure button is depressed. Moves mouse to first | 416 // Clicks on first menu, makes sure button is depressed. Moves mouse to first |
417 // child, clicks it and makes sure a navigation occurs. | 417 // child, clicks it and makes sure a navigation occurs. |
418 class BookmarkBarViewTest1 : public BookmarkBarViewEventTestBase { | 418 class BookmarkBarViewTest1 : public BookmarkBarViewEventTestBase { |
419 protected: | 419 protected: |
420 void DoTestOnMessageLoop() override { | 420 void DoTestOnMessageLoop() override { |
421 // Move the mouse to the first folder on the bookmark bar and press the | 421 // Move the mouse to the first folder on the bookmark bar and press the |
422 // mouse. | 422 // mouse. |
423 views::LabelButton* button = GetBookmarkButton(0); | 423 views::LabelButton* button = GetBookmarkButton(0); |
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1332 // Make sure the context menu is showing. | 1332 // Make sure the context menu is showing. |
1333 views::MenuItemView* menu = bb_view_->GetContextMenu(); | 1333 views::MenuItemView* menu = bb_view_->GetContextMenu(); |
1334 ASSERT_TRUE(menu && menu->GetSubmenu() && menu->GetSubmenu()->IsShowing()); | 1334 ASSERT_TRUE(menu && menu->GetSubmenu() && menu->GetSubmenu()->IsShowing()); |
1335 | 1335 |
1336 // Select the first item in the context menu (open all). | 1336 // Select the first item in the context menu (open all). |
1337 views::MenuItemView* child_menu = | 1337 views::MenuItemView* child_menu = |
1338 menu->GetSubmenu()->GetMenuItemAt(0); | 1338 menu->GetSubmenu()->GetMenuItemAt(0); |
1339 ASSERT_TRUE(child_menu != NULL); | 1339 ASSERT_TRUE(child_menu != NULL); |
1340 | 1340 |
1341 // Click and wait until the dialog box appears. | 1341 // Click and wait until the dialog box appears. |
1342 scoped_ptr<DialogWaiter> dialog_waiter(new DialogWaiter()); | 1342 std::unique_ptr<DialogWaiter> dialog_waiter(new DialogWaiter()); |
1343 ui_test_utils::MoveMouseToCenterAndPress( | 1343 ui_test_utils::MoveMouseToCenterAndPress( |
1344 child_menu, | 1344 child_menu, |
1345 ui_controls::LEFT, | 1345 ui_controls::LEFT, |
1346 ui_controls::DOWN | ui_controls::UP, | 1346 ui_controls::DOWN | ui_controls::UP, |
1347 base::Bind( | 1347 base::Bind( |
1348 &BookmarkBarViewTest12::Step4, this, base::Passed(&dialog_waiter))); | 1348 &BookmarkBarViewTest12::Step4, this, base::Passed(&dialog_waiter))); |
1349 } | 1349 } |
1350 | 1350 |
1351 void Step4(scoped_ptr<DialogWaiter> waiter) { | 1351 void Step4(std::unique_ptr<DialogWaiter> waiter) { |
1352 views::Widget* dialog = waiter->WaitForDialog(); | 1352 views::Widget* dialog = waiter->WaitForDialog(); |
1353 waiter.reset(); | 1353 waiter.reset(); |
1354 | 1354 |
1355 // Press tab to give focus to the cancel button. Wait until the widget | 1355 // Press tab to give focus to the cancel button. Wait until the widget |
1356 // receives the tab key. | 1356 // receives the tab key. |
1357 TabKeyWaiter tab_waiter(dialog); | 1357 TabKeyWaiter tab_waiter(dialog); |
1358 ASSERT_TRUE(ui_controls::SendKeyPress( | 1358 ASSERT_TRUE(ui_controls::SendKeyPress( |
1359 window_->GetNativeWindow(), ui::VKEY_TAB, false, false, false, false)); | 1359 window_->GetNativeWindow(), ui::VKEY_TAB, false, false, false, false)); |
1360 tab_waiter.WaitForTab(); | 1360 tab_waiter.WaitForTab(); |
1361 | 1361 |
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2371 ASSERT_EQ(2u, navigator_.urls().size()); | 2371 ASSERT_EQ(2u, navigator_.urls().size()); |
2372 EXPECT_EQ(navigator_.urls()[0], | 2372 EXPECT_EQ(navigator_.urls()[0], |
2373 model_->bookmark_bar_node()->GetChild(0)->GetChild(0)->url()); | 2373 model_->bookmark_bar_node()->GetChild(0)->GetChild(0)->url()); |
2374 EXPECT_EQ(navigator_.urls()[1], | 2374 EXPECT_EQ(navigator_.urls()[1], |
2375 model_->bookmark_bar_node()->GetChild(0)->GetChild(2)->url()); | 2375 model_->bookmark_bar_node()->GetChild(0)->GetChild(2)->url()); |
2376 Done(); | 2376 Done(); |
2377 } | 2377 } |
2378 }; | 2378 }; |
2379 | 2379 |
2380 VIEW_TEST(BookmarkBarViewTest27, MiddleClickOnFolderOpensAllBookmarks); | 2380 VIEW_TEST(BookmarkBarViewTest27, MiddleClickOnFolderOpensAllBookmarks); |
OLD | NEW |