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

Side by Side Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc

Issue 857433003: Update {virtual,override,final} to follow C++11 style chrome/browser/ui. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix rebase Created 5 years, 11 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/ash/launcher/chrome_launcher_controller.h" 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 #if defined(OS_CHROMEOS) 612 #if defined(OS_CHROMEOS)
613 // A browser window proxy which is able to associate an aura native window with 613 // A browser window proxy which is able to associate an aura native window with
614 // it. 614 // it.
615 class TestBrowserWindowAura : public TestBrowserWindow { 615 class TestBrowserWindowAura : public TestBrowserWindow {
616 public: 616 public:
617 // |native_window| will still be owned by the caller after the constructor 617 // |native_window| will still be owned by the caller after the constructor
618 // was called. 618 // was called.
619 explicit TestBrowserWindowAura(aura::Window* native_window) 619 explicit TestBrowserWindowAura(aura::Window* native_window)
620 : native_window_(native_window) { 620 : native_window_(native_window) {
621 } 621 }
622 virtual ~TestBrowserWindowAura() {} 622 ~TestBrowserWindowAura() override {}
623 623
624 virtual gfx::NativeWindow GetNativeWindow() const override { 624 gfx::NativeWindow GetNativeWindow() const override {
625 return native_window_.get(); 625 return native_window_.get();
626 } 626 }
627 627
628 Browser* browser() { return browser_.get(); } 628 Browser* browser() { return browser_.get(); }
629 629
630 void CreateBrowser(const Browser::CreateParams& params) { 630 void CreateBrowser(const Browser::CreateParams& params) {
631 Browser::CreateParams create_params = params; 631 Browser::CreateParams create_params = params;
632 create_params.window = this; 632 create_params.window = this;
633 browser_.reset(new Browser(create_params)); 633 browser_.reset(new Browser(create_params));
634 } 634 }
(...skipping 23 matching lines...) Expand all
658 658
659 // Watches WebContents and blocks until it is destroyed. This is needed for 659 // Watches WebContents and blocks until it is destroyed. This is needed for
660 // the destruction of a V2 application. 660 // the destruction of a V2 application.
661 class WebContentsDestroyedWatcher : public content::WebContentsObserver { 661 class WebContentsDestroyedWatcher : public content::WebContentsObserver {
662 public: 662 public:
663 explicit WebContentsDestroyedWatcher(content::WebContents* web_contents) 663 explicit WebContentsDestroyedWatcher(content::WebContents* web_contents)
664 : content::WebContentsObserver(web_contents), 664 : content::WebContentsObserver(web_contents),
665 message_loop_runner_(new content::MessageLoopRunner) { 665 message_loop_runner_(new content::MessageLoopRunner) {
666 EXPECT_TRUE(web_contents != NULL); 666 EXPECT_TRUE(web_contents != NULL);
667 } 667 }
668 virtual ~WebContentsDestroyedWatcher() {} 668 ~WebContentsDestroyedWatcher() override {}
669 669
670 // Waits until the WebContents is destroyed. 670 // Waits until the WebContents is destroyed.
671 void Wait() { 671 void Wait() {
672 message_loop_runner_->Run(); 672 message_loop_runner_->Run();
673 } 673 }
674 674
675 private: 675 private:
676 // Overridden WebContentsObserver methods. 676 // Overridden WebContentsObserver methods.
677 virtual void WebContentsDestroyed() override { 677 void WebContentsDestroyed() override { message_loop_runner_->Quit(); }
678 message_loop_runner_->Quit();
679 }
680 678
681 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; 679 scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
682 680
683 DISALLOW_COPY_AND_ASSIGN(WebContentsDestroyedWatcher); 681 DISALLOW_COPY_AND_ASSIGN(WebContentsDestroyedWatcher);
684 }; 682 };
685 683
686 // A V1 windowed application. 684 // A V1 windowed application.
687 class V1App : public TestBrowserWindow { 685 class V1App : public TestBrowserWindow {
688 public: 686 public:
689 V1App(Profile* profile, const std::string& app_name) { 687 V1App(Profile* profile, const std::string& app_name) {
(...skipping 10 matching lines...) Expand all
700 Browser::CreateParams::CreateForApp(kCrxAppPrefix + app_name, 698 Browser::CreateParams::CreateForApp(kCrxAppPrefix + app_name,
701 true /* trusted_source */, 699 true /* trusted_source */,
702 gfx::Rect(), 700 gfx::Rect(),
703 profile, 701 profile,
704 chrome::HOST_DESKTOP_TYPE_ASH); 702 chrome::HOST_DESKTOP_TYPE_ASH);
705 params.window = this; 703 params.window = this;
706 browser_.reset(new Browser(params)); 704 browser_.reset(new Browser(params));
707 chrome::AddTabAt(browser_.get(), GURL(), 0, true); 705 chrome::AddTabAt(browser_.get(), GURL(), 0, true);
708 } 706 }
709 707
710 virtual ~V1App() { 708 ~V1App() override {
711 // close all tabs. Note that we do not need to destroy the browser itself. 709 // close all tabs. Note that we do not need to destroy the browser itself.
712 browser_->tab_strip_model()->CloseAllTabs(); 710 browser_->tab_strip_model()->CloseAllTabs();
713 } 711 }
714 712
715 Browser* browser() { return browser_.get(); } 713 Browser* browser() { return browser_.get(); }
716 714
717 // TestBrowserWindow override: 715 // TestBrowserWindow override:
718 virtual gfx::NativeWindow GetNativeWindow() const override { 716 gfx::NativeWindow GetNativeWindow() const override {
719 return native_window_.get(); 717 return native_window_.get();
720 } 718 }
721 719
722 private: 720 private:
723 // The associated browser with this app. 721 // The associated browser with this app.
724 scoped_ptr<Browser> browser_; 722 scoped_ptr<Browser> browser_;
725 723
726 // The native window we use. 724 // The native window we use.
727 scoped_ptr<aura::Window> native_window_; 725 scoped_ptr<aura::Window> native_window_;
728 726
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 DISALLOW_COPY_AND_ASSIGN(V2App); 759 DISALLOW_COPY_AND_ASSIGN(V2App);
762 }; 760 };
763 761
764 // The testing framework to test multi profile scenarios. 762 // The testing framework to test multi profile scenarios.
765 class MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest 763 class MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest
766 : public ChromeLauncherControllerTest { 764 : public ChromeLauncherControllerTest {
767 protected: 765 protected:
768 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest() { 766 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest() {
769 } 767 }
770 768
771 virtual ~MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest() { 769 ~MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest() override {}
772 }
773 770
774 // Overwrite the Setup function to enable multi profile and needed objects. 771 // Overwrite the Setup function to enable multi profile and needed objects.
775 virtual void SetUp() override { 772 void SetUp() override {
776 profile_manager_.reset( 773 profile_manager_.reset(
777 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); 774 new TestingProfileManager(TestingBrowserProcess::GetGlobal()));
778 775
779 ASSERT_TRUE(profile_manager_->SetUp()); 776 ASSERT_TRUE(profile_manager_->SetUp());
780 777
781 // AvatarMenu and multiple profiles works after user logged in. 778 // AvatarMenu and multiple profiles works after user logged in.
782 profile_manager_->SetLoggedIn(true); 779 profile_manager_->SetLoggedIn(true);
783 780
784 // Initialize the UserManager singleton to a fresh FakeUserManager instance. 781 // Initialize the UserManager singleton to a fresh FakeUserManager instance.
785 user_manager_enabler_.reset( 782 user_manager_enabler_.reset(
786 new chromeos::ScopedUserManagerEnabler(new chromeos::FakeUserManager)); 783 new chromeos::ScopedUserManagerEnabler(new chromeos::FakeUserManager));
787 784
788 // Initialize the rest. 785 // Initialize the rest.
789 ChromeLauncherControllerTest::SetUp(); 786 ChromeLauncherControllerTest::SetUp();
790 787
791 // Get some base objects. 788 // Get some base objects.
792 session_delegate()->set_logged_in_users(2); 789 session_delegate()->set_logged_in_users(2);
793 shell_delegate_ = static_cast<ash::test::TestShellDelegate*>( 790 shell_delegate_ = static_cast<ash::test::TestShellDelegate*>(
794 ash::Shell::GetInstance()->delegate()); 791 ash::Shell::GetInstance()->delegate());
795 shell_delegate_->set_multi_profiles_enabled(true); 792 shell_delegate_->set_multi_profiles_enabled(true);
796 } 793 }
797 794
798 virtual void TearDown() { 795 void TearDown() override {
799 ChromeLauncherControllerTest::TearDown(); 796 ChromeLauncherControllerTest::TearDown();
800 user_manager_enabler_.reset(); 797 user_manager_enabler_.reset();
801 for (ProfileToNameMap::iterator it = created_profiles_.begin(); 798 for (ProfileToNameMap::iterator it = created_profiles_.begin();
802 it != created_profiles_.end(); ++it) 799 it != created_profiles_.end(); ++it)
803 profile_manager_->DeleteTestingProfile(it->second); 800 profile_manager_->DeleteTestingProfile(it->second);
804 801
805 // A Task is leaked if we don't destroy everything, then run the message 802 // A Task is leaked if we don't destroy everything, then run the message
806 // loop. 803 // loop.
807 base::MessageLoop::current()->PostTask(FROM_HERE, 804 base::MessageLoop::current()->PostTask(FROM_HERE,
808 base::MessageLoop::QuitClosure()); 805 base::MessageLoop::QuitClosure());
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 return v1_app; 884 return v1_app;
888 } 885 }
889 886
890 ash::test::TestSessionStateDelegate* session_delegate() { 887 ash::test::TestSessionStateDelegate* session_delegate() {
891 return static_cast<ash::test::TestSessionStateDelegate*>( 888 return static_cast<ash::test::TestSessionStateDelegate*>(
892 ash::Shell::GetInstance()->session_state_delegate()); 889 ash::Shell::GetInstance()->session_state_delegate());
893 } 890 }
894 ash::test::TestShellDelegate* shell_delegate() { return shell_delegate_; } 891 ash::test::TestShellDelegate* shell_delegate() { return shell_delegate_; }
895 892
896 // Override BrowserWithTestWindowTest: 893 // Override BrowserWithTestWindowTest:
897 virtual TestingProfile* CreateProfile() override { 894 TestingProfile* CreateProfile() override {
898 return CreateMultiUserProfile("user1"); 895 return CreateMultiUserProfile("user1");
899 } 896 }
900 virtual void DestroyProfile(TestingProfile* profile) override { 897 void DestroyProfile(TestingProfile* profile) override {
901 // Delete the profile through our profile manager. 898 // Delete the profile through our profile manager.
902 ProfileToNameMap::iterator it = created_profiles_.find(profile); 899 ProfileToNameMap::iterator it = created_profiles_.find(profile);
903 DCHECK(it != created_profiles_.end()); 900 DCHECK(it != created_profiles_.end());
904 profile_manager_->DeleteTestingProfile(it->second); 901 profile_manager_->DeleteTestingProfile(it->second);
905 created_profiles_.erase(it); 902 created_profiles_.erase(it);
906 } 903 }
907 904
908 private: 905 private:
909 typedef std::map<Profile*, std::string> ProfileToNameMap; 906 typedef std::map<Profile*, std::string> ProfileToNameMap;
910 TestingProfileManager* profile_manager() { return profile_manager_.get(); } 907 TestingProfileManager* profile_manager() { return profile_manager_.get(); }
(...skipping 1769 matching lines...) Expand 10 before | Expand all | Expand 10 after
2680 2677
2681 EXPECT_EQ(1, app_icon_loader->fetch_count()); 2678 EXPECT_EQ(1, app_icon_loader->fetch_count());
2682 ASSERT_EQ(initial_size + 1, model_->items().size()); 2679 ASSERT_EQ(initial_size + 1, model_->items().size());
2683 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); 2680 EXPECT_TRUE(launcher_controller_->IsAppPinned("1"));
2684 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); 2681 EXPECT_FALSE(launcher_controller_->IsAppPinned("0"));
2685 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); 2682 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type);
2686 2683
2687 launcher_controller_->UnpinAppWithID("1"); 2684 launcher_controller_->UnpinAppWithID("1");
2688 ASSERT_EQ(initial_size, model_->items().size()); 2685 ASSERT_EQ(initial_size, model_->items().size());
2689 } 2686 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698