BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / profiles / user_manager_mac_unittest.mm
blobe4769a1cfda956abb1f51bcc2ef6a07c2287d7aa
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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/cocoa/profiles/user_manager_mac.h"
7 #include "base/prefs/pref_service.h"
8 #include "base/run_loop.h"
9 #include "chrome/browser/profiles/profile_window.h"
10 #include "chrome/browser/ui/user_manager.h"
11 #include "chrome/common/pref_names.h"
12 #include "chrome/test/base/browser_with_test_window_test.h"
13 #include "chrome/test/base/testing_browser_process.h"
14 #include "chrome/test/base/testing_profile_manager.h"
16 class UserManagerMacTest : public BrowserWithTestWindowTest {
17  public:
18   UserManagerMacTest()
19       : testing_profile_manager_(TestingBrowserProcess::GetGlobal()) {
20   }
22   void SetUp() override {
23     BrowserWithTestWindowTest::SetUp();
24     ASSERT_TRUE(testing_profile_manager_.SetUp());
25     // Create a user to make sure the System Profile isn't the only one since it
26     // shouldn't be added to the ProfileInfoCache.
27     testing_profile_manager_.CreateTestingProfile("Default");
28     // Pre-load the system profile so we don't have to wait for the User Manager
29     // to asynchronously create it.
30     testing_profile_manager_.CreateSystemProfile();
31   }
33   void TearDown() override {
34     testing_profile_manager_.DeleteSystemProfile();
35     TestingBrowserProcess::GetGlobal()->SetProfileManager(NULL);
36     base::RunLoop().RunUntilIdle();
37     BrowserWithTestWindowTest::TearDown();
38   }
40  private:
41   TestingProfileManager testing_profile_manager_;
43   DISALLOW_COPY_AND_ASSIGN(UserManagerMacTest);
46 TEST_F(UserManagerMacTest, ShowUserManager) {
47   // Set the ProfileLastUsed pref so that SetActiveProfileToGuestIfLocked()
48   // uses a last active profile that's in the ProfileInfoCache, not default.
49   g_browser_process->local_state()->SetString(
50       prefs::kProfileLastUsed,
51       g_browser_process->profile_manager()->GetProfileInfoCache().
52           GetPathOfProfileAtIndex(0).BaseName().MaybeAsASCII());
54   EXPECT_FALSE(UserManager::IsShowing());
55   UserManager::Show(base::FilePath(),
56                     profiles::USER_MANAGER_NO_TUTORIAL,
57                     profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION);
58   EXPECT_TRUE(UserManager::IsShowing());
60   UserManager::Hide();
61   EXPECT_FALSE(UserManager::IsShowing());