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

Side by Side Diff: chrome/browser/ui/ash/chrome_new_window_delegate_browsertest.cc

Issue 1954853002: When user presses Ctrl-N, we should use the current active window's profile to determine on which p… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add test. Created 4 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
(Empty)
1 // Copyright 2016 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.
4
5 #include "ash/new_window_delegate.h"
6 #include "ash/shell.h"
7 #include "ash/wm/window_util.h"
8 #include "chrome/browser/profiles/profile_manager.h"
9 #include "chrome/browser/ui/browser_finder.h"
10 #include "chrome/test/base/in_process_browser_test.h"
11 #include "components/signin/core/account_id/account_id.h"
12 #include "components/user_manager/user_manager.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "ui/aura/window.h"
15
16 namespace {
17
18 const char kTestUserName[] = "test@test.com";
19
20 } // namespace
21
22 typedef InProcessBrowserTest ChromeNewWindowDelegateBrowserTest;
23
24 // Tests that when we open a new window by pressing 'Ctrl-N', we should use the
25 // current active window's profile to determine on which profile's desktop we
26 // should open a new window.
27 IN_PROC_BROWSER_TEST_F(ChromeNewWindowDelegateBrowserTest,
28 NewWindowForActiveWindowProfileTest) {
29 // The newly created window should be created for the current active profile.
30 ash::Shell::GetInstance()->new_window_delegate()->NewWindow(false);
31 aura::Window* window1 = ash::wm::GetActiveWindow();
32 Profile* profile1 = ProfileManager::GetActiveUserProfile();
33 EXPECT_EQ(chrome::FindBrowserWithWindow(window1)->profile(), profile1);
34
35 // Login another user and make sure the current active user changes.
36 user_manager::UserManager::Get()->UserLoggedIn(
37 AccountId::FromUserEmail(kTestUserName), kTestUserName, true);
38 Profile* profile2 = ProfileManager::GetActiveUserProfile();
39 EXPECT_NE(profile1, profile2);
40
41 CreateBrowser(profile2);
42 // The newly created window should be created for the current active window's
43 // profile, which is |profile2|.
44 ash::Shell::GetInstance()->new_window_delegate()->NewWindow(false);
45 aura::Window* window2 = ash::wm::GetActiveWindow();
46 EXPECT_EQ(chrome::FindBrowserWithWindow(window2)->profile(), profile2);
47
48 // After activating |window1|, |window1| is the current active window. And we
49 // should open a new window against |window1|'s profile.
50 ash::wm::ActivateWindow(window1);
51 ash::Shell::GetInstance()->new_window_delegate()->NewWindow(false);
52 aura::Window* window3 = ash::wm::GetActiveWindow();
53 EXPECT_EQ(chrome::FindBrowserWithWindow(window3)->profile(), profile1);
oshima 2016/05/06 18:44:14 can you also add the case when the incognito is ac
xdai1 2016/05/06 20:25:32 Done.
54 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698