OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/test/ui/ui_test.h" | 5 #include "chrome/test/ui/ui_test.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
11 #include "chrome/test/automation/automation_proxy.h" | 11 #include "chrome/test/automation/automation_proxy.h" |
12 #include "net/base/net_util.h" | 12 #include "net/base/net_util.h" |
13 | 13 |
14 typedef UITest ChromeMainTest; | 14 typedef UITest ChromeMainTest; |
15 | 15 |
16 #if !defined(OS_MACOSX) | 16 #if !defined(OS_MACOSX) |
17 | |
18 #if defined(USE_AURA) | |
19 // http://crbug.com/104650 | |
20 #define MAYBE_SecondLaunch FAILS_SecondLaunch | |
21 #define MAYBE_ReuseBrowserInstanceWhenOpeningFile \ | |
22 FAILS_ReuseBrowserInstanceWhenOpeningFile | |
23 #define MAYBE_SecondLaunchWithIncognitoUrl FAILS_SecondLaunchWithIncognitoUrl | |
24 #define MAYBE_SecondLaunchFromIncognitoWithNormalUrl \ | |
25 FAILS_SecondLaunchFromIncognitoWithNormalUrl | |
26 #else | |
27 #define MAYBE_SecondLaunch SecondLaunch | |
28 #define MAYBE_ReuseBrowserInstanceWhenOpeningFile \ | |
29 ReuseBrowserInstanceWhenOpeningFile | |
30 #define MAYBE_SecondLaunchWithIncognitoUrl SecondLaunchWithIncognitoUrl | |
31 #define MAYBE_SecondLaunchFromIncognitoWithNormalUrl \ | |
32 SecondLaunchFromIncognitoWithNormalUrl | |
33 #endif | |
34 | |
35 // These tests don't apply to the Mac version; see | 17 // These tests don't apply to the Mac version; see |
36 // LaunchAnotherBrowserBlockUntilClosed for details. | 18 // LaunchAnotherBrowserBlockUntilClosed for details. |
37 | 19 |
38 // Make sure that the second invocation creates a new window. | 20 // Make sure that the second invocation creates a new window. |
39 TEST_F(ChromeMainTest, MAYBE_SecondLaunch) { | 21 TEST_F(ChromeMainTest, SecondLaunch) { |
40 include_testing_id_ = false; | 22 include_testing_id_ = false; |
41 | 23 |
42 ASSERT_TRUE(LaunchAnotherBrowserBlockUntilClosed( | 24 ASSERT_TRUE(LaunchAnotherBrowserBlockUntilClosed( |
43 CommandLine(CommandLine::NO_PROGRAM))); | 25 CommandLine(CommandLine::NO_PROGRAM))); |
44 | 26 |
45 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2)); | 27 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2)); |
46 } | 28 } |
47 | 29 |
48 TEST_F(ChromeMainTest, MAYBE_ReuseBrowserInstanceWhenOpeningFile) { | 30 TEST_F(ChromeMainTest, ReuseBrowserInstanceWhenOpeningFile) { |
49 include_testing_id_ = false; | 31 include_testing_id_ = false; |
50 | 32 |
51 FilePath test_file = test_data_directory_.AppendASCII("empty.html"); | 33 FilePath test_file = test_data_directory_.AppendASCII("empty.html"); |
52 | 34 |
53 CommandLine command_line(CommandLine::NO_PROGRAM); | 35 CommandLine command_line(CommandLine::NO_PROGRAM); |
54 command_line.AppendArgPath(test_file); | 36 command_line.AppendArgPath(test_file); |
55 ASSERT_TRUE(LaunchAnotherBrowserBlockUntilClosed(command_line)); | 37 ASSERT_TRUE(LaunchAnotherBrowserBlockUntilClosed(command_line)); |
56 | 38 |
57 ASSERT_TRUE(automation()->IsURLDisplayed(net::FilePathToFileURL(test_file))); | 39 ASSERT_TRUE(automation()->IsURLDisplayed(net::FilePathToFileURL(test_file))); |
58 } | 40 } |
59 | 41 |
60 TEST_F(ChromeMainTest, MAYBE_SecondLaunchWithIncognitoUrl) { | 42 TEST_F(ChromeMainTest, SecondLaunchWithIncognitoUrl) { |
61 include_testing_id_ = false; | 43 include_testing_id_ = false; |
62 int num_normal_windows; | 44 int num_normal_windows; |
63 // We should start with one normal window. | 45 // We should start with one normal window. |
64 ASSERT_TRUE(automation()->GetNormalBrowserWindowCount(&num_normal_windows)); | 46 ASSERT_TRUE(automation()->GetNormalBrowserWindowCount(&num_normal_windows)); |
65 ASSERT_EQ(1, num_normal_windows); | 47 ASSERT_EQ(1, num_normal_windows); |
66 | 48 |
67 // Run with --incognito switch and an URL specified. | 49 // Run with --incognito switch and an URL specified. |
68 FilePath test_file = test_data_directory_.AppendASCII("empty.html"); | 50 FilePath test_file = test_data_directory_.AppendASCII("empty.html"); |
69 CommandLine command_line(CommandLine::NO_PROGRAM); | 51 CommandLine command_line(CommandLine::NO_PROGRAM); |
70 command_line.AppendSwitch(switches::kIncognito); | 52 command_line.AppendSwitch(switches::kIncognito); |
71 command_line.AppendArgPath(test_file); | 53 command_line.AppendArgPath(test_file); |
72 ASSERT_TRUE(LaunchAnotherBrowserBlockUntilClosed(command_line)); | 54 ASSERT_TRUE(LaunchAnotherBrowserBlockUntilClosed(command_line)); |
73 | 55 |
74 // There should be one normal and one incognito window now. | 56 // There should be one normal and one incognito window now. |
75 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2)); | 57 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2)); |
76 ASSERT_TRUE(automation()->GetNormalBrowserWindowCount(&num_normal_windows)); | 58 ASSERT_TRUE(automation()->GetNormalBrowserWindowCount(&num_normal_windows)); |
77 ASSERT_EQ(1, num_normal_windows); | 59 ASSERT_EQ(1, num_normal_windows); |
78 } | 60 } |
79 | 61 |
80 TEST_F(ChromeMainTest, MAYBE_SecondLaunchFromIncognitoWithNormalUrl) { | 62 TEST_F(ChromeMainTest, SecondLaunchFromIncognitoWithNormalUrl) { |
81 include_testing_id_ = false; | 63 include_testing_id_ = false; |
82 int num_normal_windows; | 64 int num_normal_windows; |
83 // We should start with one normal window. | 65 // We should start with one normal window. |
84 ASSERT_TRUE(automation()->GetNormalBrowserWindowCount(&num_normal_windows)); | 66 ASSERT_TRUE(automation()->GetNormalBrowserWindowCount(&num_normal_windows)); |
85 ASSERT_EQ(1, num_normal_windows); | 67 ASSERT_EQ(1, num_normal_windows); |
86 | 68 |
87 scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); | 69 scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); |
88 ASSERT_TRUE(browser_proxy.get()); | 70 ASSERT_TRUE(browser_proxy.get()); |
89 | 71 |
90 // Create an incognito window. | 72 // Create an incognito window. |
(...skipping 20 matching lines...) Expand all Loading... |
111 command_line.AppendArgPath(test_file); | 93 command_line.AppendArgPath(test_file); |
112 ASSERT_TRUE(LaunchAnotherBrowserBlockUntilClosed(command_line)); | 94 ASSERT_TRUE(LaunchAnotherBrowserBlockUntilClosed(command_line)); |
113 | 95 |
114 // There should be one normal and one incognito window now. | 96 // There should be one normal and one incognito window now. |
115 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2)); | 97 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2)); |
116 ASSERT_TRUE(automation()->GetNormalBrowserWindowCount(&num_normal_windows)); | 98 ASSERT_TRUE(automation()->GetNormalBrowserWindowCount(&num_normal_windows)); |
117 ASSERT_EQ(1, num_normal_windows); | 99 ASSERT_EQ(1, num_normal_windows); |
118 } | 100 } |
119 | 101 |
120 #endif // !OS_MACOSX | 102 #endif // !OS_MACOSX |
OLD | NEW |