browser_navigator_browsertest_chromeos.cc revision a1401311d1ab56c4ed0a474bd38c108f75cb0cd9
15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/browser_navigator_browsertest.h" 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include <string> 8a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/command_line.h" 102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/chromeos/login/chrome_restart_request.h" 11a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "chrome/browser/ui/ash/multi_user/multi_user_util.h" 12a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/browser.h" 142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/ui/browser_finder.h" 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/browser_navigator.h" 16a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "chrome/browser/ui/browser_window.h" 172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/ui/tabs/tab_strip_model.h" 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/common/chrome_switches.h" 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/test/base/ui_test_utils.h" 20c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chromeos/chromeos_switches.h" 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/web_contents.h" 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace { 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 25a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// This is a test implementation of a MultiUserWindowManager which allows to 26a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// test a visiting window on another desktop. It will install and remove itself 27a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// from the system upon creation / destruction. 28a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// The creation function gets a |browser| which is shown on |desktop_owner|'s 29a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// desktop. 30a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)class TestMultiUserWindowManager : public chrome::MultiUserWindowManager { 31a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) public: 32a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) TestMultiUserWindowManager( 33a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) Browser* visiting_browser, 34a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const std::string& desktop_owner); 35a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) virtual ~TestMultiUserWindowManager(); 36a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 37a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) aura::Window* created_window() { return created_window_; } 38a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 39a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // MultiUserWindowManager overrides: 40a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) virtual void SetWindowOwner( 41a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) aura::Window* window, const std::string& user_id) OVERRIDE; 42a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) virtual const std::string& GetWindowOwner(aura::Window* window) OVERRIDE; 43a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) virtual void ShowWindowForUser( 44a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) aura::Window* window, const std::string& user_id) OVERRIDE; 45a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) virtual bool AreWindowsSharedAmongUsers() OVERRIDE; 465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void GetOwnersOfVisibleWindows( 475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) std::set<std::string>* user_ids) OVERRIDE; 48a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) virtual bool IsWindowOnDesktopOfUser(aura::Window* window, 49a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const std::string& user_id) OVERRIDE; 50a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) virtual const std::string& GetUserPresentingWindow( 51a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) aura::Window* window) OVERRIDE; 52a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) virtual void AddUser(content::BrowserContext* profile) OVERRIDE; 535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void AddObserver(Observer* observer) OVERRIDE; 545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void RemoveObserver(Observer* observer) OVERRIDE; 55a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 56a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) private: 57a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // The window of the visiting browser. 58a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) aura::Window* browser_window_; 59a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // The owner of the visiting browser. 60a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) std::string browser_owner_; 61a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // The owner of the currently shown desktop. 62a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) std::string desktop_owner_; 63a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // The created window. 64a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) aura::Window* created_window_; 65a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // The location of the window. 66a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) std::string created_window_shown_for_; 67a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 68a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(TestMultiUserWindowManager); 69a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)}; 70a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 71a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)TestMultiUserWindowManager::TestMultiUserWindowManager( 72a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) Browser* visiting_browser, 73a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const std::string& desktop_owner) 74a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) : browser_window_(visiting_browser->window()->GetNativeWindow()), 75a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) browser_owner_(multi_user_util::GetUserIDFromProfile( 76a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) visiting_browser->profile())), 77a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) desktop_owner_(desktop_owner), 78a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) created_window_(NULL), 79a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) created_window_shown_for_(browser_owner_) { 80a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // Create a window manager for a visiting user. 81a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) chrome::MultiUserWindowManager::SetInstanceForTest( 82a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) this, 83a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED); 84a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)} 85a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 86a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)TestMultiUserWindowManager::~TestMultiUserWindowManager() { 87a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // This object is owned by the MultiUserWindowManager since the 88a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // SetInstanceForTest call. As such no uninstall is required. 89a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)} 90a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 91a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// MultiUserWindowManager overrides: 92a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)void TestMultiUserWindowManager::SetWindowOwner( 93a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) aura::Window* window, const std::string& user_id) { 94a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) NOTREACHED(); 95a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)} 96a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 97a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)const std::string& TestMultiUserWindowManager::GetWindowOwner( 98a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) aura::Window* window) { 99a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // No matter which window will get queried - all browsers belong to the 100a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // original browser's user. 101a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) return browser_owner_; 102a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)} 103a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 104a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)void TestMultiUserWindowManager::ShowWindowForUser( 105a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) aura::Window* window, 106a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const std::string& user_id) { 107a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // This class is only able to handle one additional window <-> user 108a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // association beside the creation parameters. 109a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // If no association has yet been requested remember it now. 110a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) DCHECK(!created_window_); 111a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) created_window_ = window; 112a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) created_window_shown_for_ = user_id; 113a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)} 114a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 115a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)bool TestMultiUserWindowManager::AreWindowsSharedAmongUsers() { 116a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) return browser_owner_ != desktop_owner_; 117a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)} 118a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 1195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void TestMultiUserWindowManager::GetOwnersOfVisibleWindows( 1205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) std::set<std::string>* user_ids) { 1215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 1225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 123a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)bool TestMultiUserWindowManager::IsWindowOnDesktopOfUser( 124a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) aura::Window* window, 125a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const std::string& user_id) { 126a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) return GetUserPresentingWindow(window) == user_id; 127a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)} 128a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 129a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)const std::string& TestMultiUserWindowManager::GetUserPresentingWindow( 130a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) aura::Window* window) { 131a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) if (window == browser_window_) 132a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) return desktop_owner_; 133a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) if (created_window_ && window == created_window_) 134a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) return created_window_shown_for_; 135a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // We can come here before the window gets registered. 136a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) return browser_owner_; 137a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)} 138a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 139a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void TestMultiUserWindowManager::AddUser(content::BrowserContext* profile) { 140a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)} 141a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 1425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void TestMultiUserWindowManager::AddObserver(Observer* observer) { 1435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 1445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void TestMultiUserWindowManager::RemoveObserver(Observer* observer) { 1465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 1475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)GURL GetGoogleURL() { 1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return GURL("http://www.google.com/"); 1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Subclass that tests navigation while in the Guest session. 1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class BrowserGuestSessionNavigatorTest: public BrowserNavigatorTest { 1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) protected: 1552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CommandLine command_line_copy = *command_line; 157c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) command_line_copy.AppendSwitchASCII( 158c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) chromeos::switches::kLoginProfile, "user"); 1592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) chromeos::GetOffTheRecordCommandLine(GetGoogleURL(), 1602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) command_line_copy, 1612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) command_line); 1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This test verifies that the settings page is opened in the incognito window 1665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// in Guest Session (as well as all other windows in Guest session). 1675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(BrowserGuestSessionNavigatorTest, 1685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Disposition_Settings_UseIncognitoWindow) { 1695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Browser* incognito_browser = CreateIncognitoBrowser(); 1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); 1722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(1, browser()->tab_strip_model()->count()); 1732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(1, incognito_browser->tab_strip_model()->count()); 1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Navigate to the settings page. 176a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) chrome::NavigateParams params(MakeNavigateParams(incognito_browser)); 177a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) params.disposition = SINGLETON_TAB; 178a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) params.url = GURL("chrome://chrome/settings"); 179a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) params.window_action = chrome::NavigateParams::SHOW_WINDOW; 180a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; 181a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) chrome::Navigate(¶ms); 1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Settings page should be opened in incognito window. 184a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) EXPECT_NE(browser(), params.browser); 185a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) EXPECT_EQ(incognito_browser, params.browser); 1862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(2, incognito_browser->tab_strip_model()->count()); 1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(GURL("chrome://chrome/settings"), 1882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) incognito_browser->tab_strip_model()->GetActiveWebContents()-> 1892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GetURL()); 1905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 1915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 192a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// Test that in multi user environments a newly created browser gets created 193a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// on the same desktop as the browser is shown on. 194a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(BrowserGuestSessionNavigatorTest, 195a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) Browser_Gets_Created_On_Visiting_Desktop) { 196a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // Test 1: Test that a browser created from a visiting browser will be on the 197a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // same visiting desktop. 198a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) { 199a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const std::string desktop_user_id = "desktop_user_id@fake.com"; 200a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) TestMultiUserWindowManager* manager = 201a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) new TestMultiUserWindowManager(browser(), desktop_user_id); 202a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 203a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); 204a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 205a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // Navigate to the settings page. 206a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) chrome::NavigateParams params(MakeNavigateParams(browser())); 207a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) params.disposition = NEW_POPUP; 208a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) params.url = GURL("chrome://chrome/settings"); 209a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) params.window_action = chrome::NavigateParams::SHOW_WINDOW; 210a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; 211a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) params.browser = browser(); 212a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) chrome::Navigate(¶ms); 213a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 214a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); 215a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 216a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) aura::Window* created_window = manager->created_window(); 217a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) ASSERT_TRUE(created_window); 218a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) EXPECT_TRUE(manager->IsWindowOnDesktopOfUser(created_window, 219a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) desktop_user_id)); 220a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) } 221a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // Test 2: Test that a window which is not visiting does not cause an owner 222a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // assignment of a newly created browser. 223a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) { 224a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) std::string browser_owner = 225a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) multi_user_util::GetUserIDFromProfile(browser()->profile()); 226a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) TestMultiUserWindowManager* manager = 227a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) new TestMultiUserWindowManager(browser(), browser_owner); 228a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 229a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // Navigate to the settings page. 230a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) chrome::NavigateParams params(MakeNavigateParams(browser())); 231a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) params.disposition = NEW_POPUP; 232a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) params.url = GURL("chrome://chrome/settings"); 233a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) params.window_action = chrome::NavigateParams::SHOW_WINDOW; 234a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; 235a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) params.browser = browser(); 236a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) chrome::Navigate(¶ms); 237a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 238a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) EXPECT_EQ(3u, chrome::GetTotalBrowserCount()); 239a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 240a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // The ShowWindowForUser should not have been called since the window is 241a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // already on the correct desktop. 242a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) ASSERT_FALSE(manager->created_window()); 243a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) } 244a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)} 245a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 2465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace 247