- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / browser_navigator_browsertest_chromeos.cc
1 // Copyright (c) 2012 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 "chrome/browser/ui/browser_navigator_browsertest.h"
6
7 #include "base/command_line.h"
8 #include "chrome/browser/chromeos/login/chrome_restart_request.h"
9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_finder.h"
11 #include "chrome/browser/ui/browser_navigator.h"
12 #include "chrome/browser/ui/tabs/tab_strip_model.h"
13 #include "chrome/common/chrome_switches.h"
14 #include "chrome/test/base/ui_test_utils.h"
15 #include "chromeos/chromeos_switches.h"
16 #include "content/public/browser/web_contents.h"
17
18 namespace {
19
20 GURL GetGoogleURL() {
21   return GURL("http://www.google.com/");
22 }
23
24 // Subclass that tests navigation while in the Guest session.
25 class BrowserGuestSessionNavigatorTest: public BrowserNavigatorTest {
26  protected:
27   virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
28     CommandLine command_line_copy = *command_line;
29     command_line_copy.AppendSwitchASCII(
30         chromeos::switches::kLoginProfile, "user");
31     chromeos::GetOffTheRecordCommandLine(GetGoogleURL(),
32                                          command_line_copy,
33                                          command_line);
34   }
35 };
36
37 // This test verifies that the settings page is opened in the incognito window
38 // in Guest Session (as well as all other windows in Guest session).
39 IN_PROC_BROWSER_TEST_F(BrowserGuestSessionNavigatorTest,
40                        Disposition_Settings_UseIncognitoWindow) {
41   Browser* incognito_browser = CreateIncognitoBrowser();
42
43   EXPECT_EQ(2u, chrome::GetTotalBrowserCount());
44   EXPECT_EQ(1, browser()->tab_strip_model()->count());
45   EXPECT_EQ(1, incognito_browser->tab_strip_model()->count());
46
47   // Navigate to the settings page.
48   chrome::NavigateParams p(MakeNavigateParams(incognito_browser));
49   p.disposition = SINGLETON_TAB;
50   p.url = GURL("chrome://chrome/settings");
51   p.window_action = chrome::NavigateParams::SHOW_WINDOW;
52   p.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE;
53   chrome::Navigate(&p);
54
55   // Settings page should be opened in incognito window.
56   EXPECT_NE(browser(), p.browser);
57   EXPECT_EQ(incognito_browser, p.browser);
58   EXPECT_EQ(2, incognito_browser->tab_strip_model()->count());
59   EXPECT_EQ(GURL("chrome://chrome/settings"),
60             incognito_browser->tab_strip_model()->GetActiveWebContents()->
61                 GetURL());
62 }
63
64 }  // namespace