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

Side by Side Diff: chrome/browser/ui/browser_finder_chromeos_unittest.cc

Issue 2504513002: Make FakeChromeUserManager subclass of ChromeUserManager (Closed)
Patch Set: Addressed comments Created 4 years, 1 month 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 (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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/browser_finder.h" 5 #include "chrome/browser/ui/browser_finder.h"
6 6
7 #include "ash/common/test/test_session_state_delegate.h" 7 #include "ash/common/test/test_session_state_delegate.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/test/ash_test_helper.h" 9 #include "ash/test/ash_test_helper.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
11 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 12 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
12 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" 13 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
13 #include "chrome/browser/chromeos/profiles/profile_helper.h" 14 #include "chrome/browser/chromeos/profiles/profile_helper.h"
14 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" 15 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
15 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" 16 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h"
16 #include "chrome/test/base/browser_with_test_window_test.h" 17 #include "chrome/test/base/browser_with_test_window_test.h"
17 #include "chrome/test/base/test_browser_window_aura.h" 18 #include "chrome/test/base/test_browser_window_aura.h"
18 #include "chrome/test/base/testing_browser_process.h" 19 #include "chrome/test/base/testing_browser_process.h"
19 #include "chrome/test/base/testing_profile_manager.h" 20 #include "chrome/test/base/testing_profile_manager.h"
20 #include "components/signin/core/account_id/account_id.h" 21 #include "components/signin/core/account_id/account_id.h"
21 #include "components/user_manager/fake_user_manager.h"
22 #include "components/user_manager/user.h" 22 #include "components/user_manager/user.h"
23 23
24 namespace test { 24 namespace test {
25 25
26 namespace { 26 namespace {
27 27
28 const char kTestAccount1[] = "user1@test.com"; 28 const char kTestAccount1[] = "user1@test.com";
29 const char kTestAccount2[] = "user2@test.com"; 29 const char kTestAccount2[] = "user2@test.com";
30 30
31 } // namespace 31 } // namespace
32 32
33 class BrowserFinderChromeOSTest : public BrowserWithTestWindowTest { 33 class BrowserFinderChromeOSTest : public BrowserWithTestWindowTest {
34 protected: 34 protected:
35 BrowserFinderChromeOSTest() 35 BrowserFinderChromeOSTest()
36 : multi_user_window_manager_(nullptr), 36 : multi_user_window_manager_(nullptr),
37 fake_user_manager_(new user_manager::FakeUserManager), 37 fake_user_manager_(new chromeos::FakeChromeUserManager),
38 user_manager_enabler_(fake_user_manager_) {} 38 user_manager_enabler_(fake_user_manager_) {}
39 39
40 TestingProfile* CreateMultiUserProfile(const AccountId& account_id) { 40 TestingProfile* CreateMultiUserProfile(const AccountId& account_id) {
41 TestingProfile* profile = 41 TestingProfile* profile =
42 profile_manager_->CreateTestingProfile(account_id.GetUserEmail()); 42 profile_manager_->CreateTestingProfile(account_id.GetUserEmail());
43 const user_manager::User* user = fake_user_manager_->AddUser(account_id); 43 const user_manager::User* user = fake_user_manager_->AddUser(account_id);
44 chromeos::ProfileHelper::Get()->SetUserToProfileMappingForTesting( 44 chromeos::ProfileHelper::Get()->SetUserToProfileMappingForTesting(
45 const_cast<user_manager::User*>(user), profile); 45 const_cast<user_manager::User*>(user), profile);
46 chromeos::ProfileHelper::Get()->SetProfileToUserMappingForTesting( 46 chromeos::ProfileHelper::Get()->SetProfileToUserMappingForTesting(
47 const_cast<user_manager::User*>(user)); 47 const_cast<user_manager::User*>(user));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 return CreateMultiUserProfile(test_account_id1_); 93 return CreateMultiUserProfile(test_account_id1_);
94 } 94 }
95 95
96 void DestroyProfile(TestingProfile* test_profile) override { 96 void DestroyProfile(TestingProfile* test_profile) override {
97 profile_manager_->DeleteTestingProfile(test_profile->GetProfileUserName()); 97 profile_manager_->DeleteTestingProfile(test_profile->GetProfileUserName());
98 } 98 }
99 99
100 TestingProfile* second_profile_; 100 TestingProfile* second_profile_;
101 std::unique_ptr<TestingProfileManager> profile_manager_; 101 std::unique_ptr<TestingProfileManager> profile_manager_;
102 chrome::MultiUserWindowManagerChromeOS* multi_user_window_manager_; 102 chrome::MultiUserWindowManagerChromeOS* multi_user_window_manager_;
103 user_manager::FakeUserManager* fake_user_manager_; // Not owned. 103 chromeos::FakeChromeUserManager* fake_user_manager_; // Not owned.
msw 2016/11/17 18:31:22 ditto nit
yoshiki 2016/11/18 15:54:15 Done.
104 chromeos::ScopedUserManagerEnabler user_manager_enabler_; 104 chromeos::ScopedUserManagerEnabler user_manager_enabler_;
105 105
106 DISALLOW_COPY_AND_ASSIGN(BrowserFinderChromeOSTest); 106 DISALLOW_COPY_AND_ASSIGN(BrowserFinderChromeOSTest);
107 }; 107 };
108 108
109 TEST_F(BrowserFinderChromeOSTest, IncognitoBrowserMatchTest) { 109 TEST_F(BrowserFinderChromeOSTest, IncognitoBrowserMatchTest) {
110 // GetBrowserCount() use kMatchAll to find all browser windows for profile(). 110 // GetBrowserCount() use kMatchAll to find all browser windows for profile().
111 EXPECT_EQ(1u, chrome::GetBrowserCount(profile())); 111 EXPECT_EQ(1u, chrome::GetBrowserCount(profile()));
112 EXPECT_TRUE(chrome::FindAnyBrowser(profile(), true)); 112 EXPECT_TRUE(chrome::FindAnyBrowser(profile(), true));
113 EXPECT_TRUE(chrome::FindAnyBrowser(profile(), false)); 113 EXPECT_TRUE(chrome::FindAnyBrowser(profile(), false));
(...skipping 25 matching lines...) Expand all
139 // Move the browser window to another user's desktop. Then no window should 139 // Move the browser window to another user's desktop. Then no window should
140 // be available for the current profile. 140 // be available for the current profile.
141 GetUserWindowManager()->ShowWindowForUser( 141 GetUserWindowManager()->ShowWindowForUser(
142 browser->window()->GetNativeWindow(), test_account_id2_); 142 browser->window()->GetNativeWindow(), test_account_id2_);
143 EXPECT_EQ(0u, chrome::GetBrowserCount(profile())); 143 EXPECT_EQ(0u, chrome::GetBrowserCount(profile()));
144 EXPECT_FALSE(chrome::FindAnyBrowser(profile(), true)); 144 EXPECT_FALSE(chrome::FindAnyBrowser(profile(), true));
145 EXPECT_FALSE(chrome::FindAnyBrowser(profile(), false)); 145 EXPECT_FALSE(chrome::FindAnyBrowser(profile(), false));
146 } 146 }
147 147
148 } // namespace test 148 } // namespace test
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698