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

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

Issue 253063002: CleanUp: Introduce UserInfo. Move session_state stuff to ash/session. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix tests Created 6 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 | Annotate | Revision Log
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 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kMultiProfiles); 792 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kMultiProfiles);
793 793
794 // Initialize the UserManager singleton to a fresh FakeUserManager instance. 794 // Initialize the UserManager singleton to a fresh FakeUserManager instance.
795 user_manager_enabler_.reset( 795 user_manager_enabler_.reset(
796 new chromeos::ScopedUserManagerEnabler(new chromeos::FakeUserManager)); 796 new chromeos::ScopedUserManagerEnabler(new chromeos::FakeUserManager));
797 797
798 // Initialize the rest. 798 // Initialize the rest.
799 ChromeLauncherControllerTest::SetUp(); 799 ChromeLauncherControllerTest::SetUp();
800 800
801 // Get some base objects. 801 // Get some base objects.
802 session_delegate_ = static_cast<ash::test::TestSessionStateDelegate*>( 802 session_delegate()->set_logged_in_users(2);
803 ash::Shell::GetInstance()->session_state_delegate());
804 session_delegate_->set_logged_in_users(2);
805 shell_delegate_ = static_cast<ash::test::TestShellDelegate*>( 803 shell_delegate_ = static_cast<ash::test::TestShellDelegate*>(
806 ash::Shell::GetInstance()->delegate()); 804 ash::Shell::GetInstance()->delegate());
807 shell_delegate_->set_multi_profiles_enabled(true); 805 shell_delegate_->set_multi_profiles_enabled(true);
808 } 806 }
809 807
810 virtual void TearDown() { 808 virtual void TearDown() {
811 ChromeLauncherControllerTest::TearDown(); 809 ChromeLauncherControllerTest::TearDown();
812 user_manager_enabler_.reset(); 810 user_manager_enabler_.reset();
813 for (ProfileToNameMap::iterator it = created_profiles_.begin(); 811 for (ProfileToNameMap::iterator it = created_profiles_.begin();
814 it != created_profiles_.end(); ++it) 812 it != created_profiles_.end(); ++it)
815 profile_manager_->DeleteTestingProfile(it->second); 813 profile_manager_->DeleteTestingProfile(it->second);
816 814
817 // A Task is leaked if we don't destroy everything, then run the message 815 // A Task is leaked if we don't destroy everything, then run the message
818 // loop. 816 // loop.
819 base::MessageLoop::current()->PostTask(FROM_HERE, 817 base::MessageLoop::current()->PostTask(FROM_HERE,
820 base::MessageLoop::QuitClosure()); 818 base::MessageLoop::QuitClosure());
821 base::MessageLoop::current()->Run(); 819 base::MessageLoop::current()->Run();
822 } 820 }
823 821
824 // Creates a profile for a given |user_name|. Note that this class will keep 822 // Creates a profile for a given |user_name|. Note that this class will keep
825 // the ownership of the created object. 823 // the ownership of the created object.
826 TestingProfile* CreateMultiUserProfile(const std::string& user_name) { 824 TestingProfile* CreateMultiUserProfile(const std::string& user_name) {
827 std::string email_string = user_name + "@example.com"; 825 std::string email_string = user_name + "@example.com";
828 826 static_cast<ash::test::TestSessionStateDelegate*>(
827 ash::Shell::GetInstance()->session_state_delegate())
828 ->AddUser(email_string);
829 // Add a user to the fake user manager. 829 // Add a user to the fake user manager.
830 session_delegate()->AddUser(email_string);
830 GetFakeUserManager()->AddUser(email_string); 831 GetFakeUserManager()->AddUser(email_string);
831 832
832 GetFakeUserManager()->UserLoggedIn( 833 GetFakeUserManager()->UserLoggedIn(
833 email_string, 834 email_string,
834 email_string + kUserIdHashSuffix, 835 email_string + kUserIdHashSuffix,
835 false); 836 false);
836 837
837 std::string profile_name = 838 std::string profile_name =
838 chrome::kProfileDirPrefix + email_string + kUserIdHashSuffix; 839 chrome::kProfileDirPrefix + email_string + kUserIdHashSuffix;
839 TestingProfile* profile = profile_manager()->CreateTestingProfile( 840 TestingProfile* profile = profile_manager()->CreateTestingProfile(
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 app_tab_helper->SetAppID( 898 app_tab_helper->SetAppID(
898 v1_app->browser()->tab_strip_model()->GetWebContentsAt(0), 899 v1_app->browser()->tab_strip_model()->GetWebContentsAt(0),
899 app_name); 900 app_name);
900 SetAppTabHelper(app_tab_helper); 901 SetAppTabHelper(app_tab_helper);
901 902
902 NavigateAndCommitActiveTabWithTitle( 903 NavigateAndCommitActiveTabWithTitle(
903 v1_app->browser(), GURL(url), ASCIIToUTF16("")); 904 v1_app->browser(), GURL(url), ASCIIToUTF16(""));
904 return v1_app; 905 return v1_app;
905 } 906 }
906 907
907 ash::test::TestSessionStateDelegate* 908 ash::test::TestSessionStateDelegate* session_delegate() {
908 session_delegate() { return session_delegate_; } 909 return static_cast<ash::test::TestSessionStateDelegate*>(
910 ash::Shell::GetInstance()->session_state_delegate());
911 }
909 ash::test::TestShellDelegate* shell_delegate() { return shell_delegate_; } 912 ash::test::TestShellDelegate* shell_delegate() { return shell_delegate_; }
910 913
911 // Override BrowserWithTestWindowTest: 914 // Override BrowserWithTestWindowTest:
912 virtual TestingProfile* CreateProfile() OVERRIDE { 915 virtual TestingProfile* CreateProfile() OVERRIDE {
913 return CreateMultiUserProfile("user1"); 916 return CreateMultiUserProfile("user1");
914 } 917 }
915 virtual void DestroyProfile(TestingProfile* profile) OVERRIDE { 918 virtual void DestroyProfile(TestingProfile* profile) OVERRIDE {
916 // Delete the profile through our profile manager. 919 // Delete the profile through our profile manager.
917 ProfileToNameMap::iterator it = created_profiles_.find(profile); 920 ProfileToNameMap::iterator it = created_profiles_.find(profile);
918 DCHECK(it != created_profiles_.end()); 921 DCHECK(it != created_profiles_.end());
(...skipping 10 matching lines...) Expand all
929 TestingProfileManager* profile_manager() { return profile_manager_.get(); } 932 TestingProfileManager* profile_manager() { return profile_manager_.get(); }
930 933
931 chromeos::FakeUserManager* GetFakeUserManager() { 934 chromeos::FakeUserManager* GetFakeUserManager() {
932 return static_cast<chromeos::FakeUserManager*>( 935 return static_cast<chromeos::FakeUserManager*>(
933 chromeos::UserManager::Get()); 936 chromeos::UserManager::Get());
934 } 937 }
935 938
936 scoped_ptr<TestingProfileManager> profile_manager_; 939 scoped_ptr<TestingProfileManager> profile_manager_;
937 scoped_ptr<chromeos::ScopedUserManagerEnabler> user_manager_enabler_; 940 scoped_ptr<chromeos::ScopedUserManagerEnabler> user_manager_enabler_;
938 941
939 ash::test::TestSessionStateDelegate* session_delegate_;
940 ash::test::TestShellDelegate* shell_delegate_; 942 ash::test::TestShellDelegate* shell_delegate_;
941 943
942 ProfileToNameMap created_profiles_; 944 ProfileToNameMap created_profiles_;
943 945
944 DISALLOW_COPY_AND_ASSIGN( 946 DISALLOW_COPY_AND_ASSIGN(
945 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest); 947 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest);
946 }; 948 };
947 #endif // defined(OS_CHROMEOS) 949 #endif // defined(OS_CHROMEOS)
948 950
949 951
(...skipping 1747 matching lines...) Expand 10 before | Expand all | Expand 10 after
2697 2699
2698 EXPECT_EQ(1, app_icon_loader->fetch_count()); 2700 EXPECT_EQ(1, app_icon_loader->fetch_count());
2699 ASSERT_EQ(initial_size + 1, model_->items().size()); 2701 ASSERT_EQ(initial_size + 1, model_->items().size());
2700 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); 2702 EXPECT_TRUE(launcher_controller_->IsAppPinned("1"));
2701 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); 2703 EXPECT_FALSE(launcher_controller_->IsAppPinned("0"));
2702 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); 2704 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type);
2703 2705
2704 launcher_controller_->UnpinAppWithID("1"); 2706 launcher_controller_->UnpinAppWithID("1");
2705 ASSERT_EQ(initial_size, model_->items().size()); 2707 ASSERT_EQ(initial_size, model_->items().size());
2706 } 2708 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698