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

Side by Side Diff: chrome/browser/ui/toolbar/browser_actions_bar_browsertest.cc

Issue 2839373003: struct UnloadedExtensionInfo -> enum UnloadedExtensionInfoReason (Closed)
Patch Set: Rebase Created 3 years, 7 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/ui/toolbar/browser_actions_bar_browsertest.h" 5 #include "chrome/browser/ui/toolbar/browser_actions_bar_browsertest.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 base::RunLoop().RunUntilIdle(); 518 base::RunLoop().RunUntilIdle();
519 EXPECT_TRUE(browser_actions_bar()->HasPopup()); 519 EXPECT_TRUE(browser_actions_bar()->HasPopup());
520 EXPECT_EQ(1, browser_actions_bar()->VisibleBrowserActions()); 520 EXPECT_EQ(1, browser_actions_bar()->VisibleBrowserActions());
521 521
522 { 522 {
523 content::WindowedNotificationObserver observer( 523 content::WindowedNotificationObserver observer(
524 extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED, 524 extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED,
525 content::NotificationService::AllSources()); 525 content::NotificationService::AllSources());
526 // Remove the extension. Nothing should crash. 526 // Remove the extension. Nothing should crash.
527 extension_service()->UnloadExtension( 527 extension_service()->UnloadExtension(
528 extension->id(), 528 extension->id(), extensions::UnloadedExtensionReason::UNINSTALL);
529 extensions::UnloadedExtensionInfo::REASON_UNINSTALL);
530 observer.Wait(); 529 observer.Wait();
531 } 530 }
532 531
533 EXPECT_EQ(0, browser_actions_bar()->VisibleBrowserActions()); 532 EXPECT_EQ(0, browser_actions_bar()->VisibleBrowserActions());
534 EXPECT_EQ(0, overflow_bar->VisibleBrowserActions()); 533 EXPECT_EQ(0, overflow_bar->VisibleBrowserActions());
535 EXPECT_EQ(0u, toolbar_model()->toolbar_items().size()); 534 EXPECT_EQ(0u, toolbar_model()->toolbar_items().size());
536 } 535 }
537 536
538 // Test that page action popups work with the toolbar redesign. 537 // Test that page action popups work with the toolbar redesign.
539 IN_PROC_BROWSER_TEST_F(BrowserActionsBarBrowserTest, 538 IN_PROC_BROWSER_TEST_F(BrowserActionsBarBrowserTest,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 toolbar_actions_bar->PopOutAction(toolbar_actions_bar->GetActions()[2], false, 585 toolbar_actions_bar->PopOutAction(toolbar_actions_bar->GetActions()[2], false,
587 closure); 586 closure);
588 EXPECT_EQ(2, browser_actions_bar()->VisibleBrowserActions()); 587 EXPECT_EQ(2, browser_actions_bar()->VisibleBrowserActions());
589 ASSERT_TRUE(toolbar_actions_bar->popped_out_action()); 588 ASSERT_TRUE(toolbar_actions_bar->popped_out_action());
590 EXPECT_EQ(extension3->id(), 589 EXPECT_EQ(extension3->id(),
591 toolbar_actions_bar->popped_out_action()->GetId()); 590 toolbar_actions_bar->popped_out_action()->GetId());
592 591
593 // Remove extension 2 - there should still be one left in the overflow 592 // Remove extension 2 - there should still be one left in the overflow
594 // (extension 2) and one left on the main bar (extension 1). 593 // (extension 2) and one left on the main bar (extension 1).
595 extension_service()->UnloadExtension( 594 extension_service()->UnloadExtension(
596 extension3->id(), extensions::UnloadedExtensionInfo::REASON_DISABLE); 595 extension3->id(), extensions::UnloadedExtensionReason::DISABLE);
597 EXPECT_EQ(1, browser_actions_bar()->VisibleBrowserActions()); 596 EXPECT_EQ(1, browser_actions_bar()->VisibleBrowserActions());
598 EXPECT_EQ(2, browser_actions_bar()->NumberOfBrowserActions()); 597 EXPECT_EQ(2, browser_actions_bar()->NumberOfBrowserActions());
599 EXPECT_FALSE(toolbar_actions_bar->popped_out_action()); 598 EXPECT_FALSE(toolbar_actions_bar->popped_out_action());
600 599
601 // Add back extension 3, and reduce visible size to 0. 600 // Add back extension 3, and reduce visible size to 0.
602 extension_service()->AddExtension(extension3.get()); 601 extension_service()->AddExtension(extension3.get());
603 toolbar_model()->SetVisibleIconCount(0); 602 toolbar_model()->SetVisibleIconCount(0);
604 EXPECT_EQ(0, browser_actions_bar()->VisibleBrowserActions()); 603 EXPECT_EQ(0, browser_actions_bar()->VisibleBrowserActions());
605 EXPECT_EQ(3, browser_actions_bar()->NumberOfBrowserActions()); 604 EXPECT_EQ(3, browser_actions_bar()->NumberOfBrowserActions());
606 605
607 // Pop out extension 2 (index 1). 606 // Pop out extension 2 (index 1).
608 EXPECT_EQ(extension2->id(), toolbar_actions_bar->GetActions()[1]->GetId()); 607 EXPECT_EQ(extension2->id(), toolbar_actions_bar->GetActions()[1]->GetId());
609 toolbar_actions_bar->PopOutAction(toolbar_actions_bar->GetActions()[1], false, 608 toolbar_actions_bar->PopOutAction(toolbar_actions_bar->GetActions()[1], false,
610 closure); 609 closure);
611 EXPECT_EQ(1, browser_actions_bar()->VisibleBrowserActions()); 610 EXPECT_EQ(1, browser_actions_bar()->VisibleBrowserActions());
612 ASSERT_TRUE(toolbar_actions_bar->popped_out_action()); 611 ASSERT_TRUE(toolbar_actions_bar->popped_out_action());
613 EXPECT_EQ(extension2->id(), 612 EXPECT_EQ(extension2->id(),
614 toolbar_actions_bar->popped_out_action()->GetId()); 613 toolbar_actions_bar->popped_out_action()->GetId());
615 614
616 // Remove extension 2 - the remaining two should both be overflowed. 615 // Remove extension 2 - the remaining two should both be overflowed.
617 extension_service()->UnloadExtension( 616 extension_service()->UnloadExtension(
618 extension2->id(), extensions::UnloadedExtensionInfo::REASON_DISABLE); 617 extension2->id(), extensions::UnloadedExtensionReason::DISABLE);
619 EXPECT_EQ(0, browser_actions_bar()->VisibleBrowserActions()); 618 EXPECT_EQ(0, browser_actions_bar()->VisibleBrowserActions());
620 EXPECT_EQ(2, browser_actions_bar()->NumberOfBrowserActions()); 619 EXPECT_EQ(2, browser_actions_bar()->NumberOfBrowserActions());
621 EXPECT_FALSE(toolbar_actions_bar->popped_out_action()); 620 EXPECT_FALSE(toolbar_actions_bar->popped_out_action());
622 621
623 // Finally, set visible count to 1, pop out extension 1, and remove it. There 622 // Finally, set visible count to 1, pop out extension 1, and remove it. There
624 // should only be one action left on the bar. 623 // should only be one action left on the bar.
625 toolbar_model()->SetVisibleIconCount(1); 624 toolbar_model()->SetVisibleIconCount(1);
626 EXPECT_EQ(1, browser_actions_bar()->VisibleBrowserActions()); 625 EXPECT_EQ(1, browser_actions_bar()->VisibleBrowserActions());
627 EXPECT_EQ(extension3->id(), toolbar_actions_bar->GetActions()[1]->GetId()); 626 EXPECT_EQ(extension3->id(), toolbar_actions_bar->GetActions()[1]->GetId());
628 toolbar_actions_bar->PopOutAction(toolbar_actions_bar->GetActions()[1], false, 627 toolbar_actions_bar->PopOutAction(toolbar_actions_bar->GetActions()[1], false,
629 closure); 628 closure);
630 EXPECT_EQ(2, browser_actions_bar()->VisibleBrowserActions()); 629 EXPECT_EQ(2, browser_actions_bar()->VisibleBrowserActions());
631 ASSERT_TRUE(toolbar_actions_bar->popped_out_action()); 630 ASSERT_TRUE(toolbar_actions_bar->popped_out_action());
632 EXPECT_EQ(extension3->id(), 631 EXPECT_EQ(extension3->id(),
633 toolbar_actions_bar->popped_out_action()->GetId()); 632 toolbar_actions_bar->popped_out_action()->GetId());
634 extension_service()->UnloadExtension( 633 extension_service()->UnloadExtension(
635 extension3->id(), extensions::UnloadedExtensionInfo::REASON_DISABLE); 634 extension3->id(), extensions::UnloadedExtensionReason::DISABLE);
636 EXPECT_EQ(1, browser_actions_bar()->VisibleBrowserActions()); 635 EXPECT_EQ(1, browser_actions_bar()->VisibleBrowserActions());
637 EXPECT_EQ(1, browser_actions_bar()->NumberOfBrowserActions()); 636 EXPECT_EQ(1, browser_actions_bar()->NumberOfBrowserActions());
638 EXPECT_FALSE(toolbar_actions_bar->popped_out_action()); 637 EXPECT_FALSE(toolbar_actions_bar->popped_out_action());
639 } 638 }
640 639
641 // A test that runs in incognito mode. 640 // A test that runs in incognito mode.
642 class BrowserActionsBarIncognitoTest : public BrowserActionsBarBrowserTest { 641 class BrowserActionsBarIncognitoTest : public BrowserActionsBarBrowserTest {
643 public: 642 public:
644 void SetUpCommandLine(base::CommandLine* command_line) override { 643 void SetUpCommandLine(base::CommandLine* command_line) override {
645 BrowserActionsBarBrowserTest::SetUpCommandLine(command_line); 644 BrowserActionsBarBrowserTest::SetUpCommandLine(command_line);
(...skipping 25 matching lines...) Expand all
671 ASSERT_EQ(1u, actions.size()); 670 ASSERT_EQ(1u, actions.size());
672 gfx::Image icon = actions[0]->GetIcon( 671 gfx::Image icon = actions[0]->GetIcon(
673 second_browser->tab_strip_model()->GetActiveWebContents(), 672 second_browser->tab_strip_model()->GetActiveWebContents(),
674 gfx::Size(ToolbarActionsBar::IconWidth(false), 673 gfx::Size(ToolbarActionsBar::IconWidth(false),
675 ToolbarActionsBar::IconHeight())); 674 ToolbarActionsBar::IconHeight()));
676 const gfx::ImageSkia* skia = icon.ToImageSkia(); 675 const gfx::ImageSkia* skia = icon.ToImageSkia();
677 ASSERT_TRUE(skia); 676 ASSERT_TRUE(skia);
678 // Force the image to try and load a representation. 677 // Force the image to try and load a representation.
679 skia->GetRepresentation(2.0); 678 skia->GetRepresentation(2.0);
680 } 679 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/location_bar/location_bar.cc ('k') | chrome/browser/ui/toolbar/component_toolbar_actions_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698