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 "content/public/test/content_browser_test.h" | 5 #include "content/public/test/content_browser_test.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/process/launch.h" | 9 #include "base/process/launch.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "base/test/launcher/test_launcher.h" | 12 #include "base/test/launcher/test_launcher.h" |
13 #include "base/threading/thread_restrictions.h" | 13 #include "base/threading/thread_restrictions.h" |
14 #include "base/threading/thread_task_runner_handle.h" | 14 #include "base/threading/thread_task_runner_handle.h" |
15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
16 #include "content/public/browser/render_process_host.h" | 16 #include "content/public/browser/render_process_host.h" |
17 #include "content/public/browser/render_process_host_observer.h" | 17 #include "content/public/browser/render_process_host_observer.h" |
18 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
19 #include "content/public/common/content_switches.h" | 19 #include "content/public/common/content_switches.h" |
20 #include "content/public/test/browser_test_utils.h" | 20 #include "content/public/test/browser_test_utils.h" |
21 #include "content/public/test/content_browser_test_utils.h" | 21 #include "content/public/test/content_browser_test_utils.h" |
22 #include "content/public/test/test_launcher.h" | 22 #include "content/public/test/test_launcher.h" |
23 #include "content/public/test/test_utils.h" | 23 #include "content/public/test/test_utils.h" |
24 #include "content/shell/browser/shell.h" | 24 #include "content/shell/browser/shell.h" |
25 #include "content/shell/common/shell_switches.h" | 25 #include "content/shell/common/shell_switches.h" |
26 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
27 | 27 |
28 #if defined(OS_WIN) | |
29 #include "base/win/windows_version.h" | |
30 #endif | |
31 | |
32 namespace content { | 28 namespace content { |
33 | 29 |
34 // Disabled on official builds because symbolization in sandboxes processes | 30 // Disabled on official builds because symbolization in sandboxes processes |
35 // opens up security holes. | 31 // opens up security holes. |
36 // On Android symbolization happens in one step after all the tests ran, so this | 32 // On Android symbolization happens in one step after all the tests ran, so this |
37 // test doesn't work there. | 33 // test doesn't work there. |
38 // TODO(mac): figure out why symbolization doesn't happen in the renderer. | 34 // TODO(mac): figure out why symbolization doesn't happen in the renderer. |
39 // http://crbug.com/521456 | 35 // http://crbug.com/521456 |
40 // TODO(win): send PDB files for component build. http://crbug.com/521459 | 36 // TODO(win): send PDB files for component build. http://crbug.com/521459 |
41 #if !defined(OFFICIAL_BUILD) && !defined(OS_ANDROID) && !defined(OS_MACOSX) && \ | 37 #if !defined(OFFICIAL_BUILD) && !defined(OS_ANDROID) && !defined(OS_MACOSX) && \ |
(...skipping 24 matching lines...) Expand all Loading... |
66 scoped_refptr<MessageLoopRunner> message_loop_runner = new MessageLoopRunner; | 62 scoped_refptr<MessageLoopRunner> message_loop_runner = new MessageLoopRunner; |
67 CrashObserver crash_observer(message_loop_runner->QuitClosure()); | 63 CrashObserver crash_observer(message_loop_runner->QuitClosure()); |
68 shell()->web_contents()->GetRenderProcessHost()->AddObserver(&crash_observer); | 64 shell()->web_contents()->GetRenderProcessHost()->AddObserver(&crash_observer); |
69 | 65 |
70 NavigateToURL(shell(), GURL("chrome:crash")); | 66 NavigateToURL(shell(), GURL("chrome:crash")); |
71 message_loop_runner->Run(); | 67 message_loop_runner->Run(); |
72 } | 68 } |
73 | 69 |
74 // Tests that browser tests print the callstack when a child process crashes. | 70 // Tests that browser tests print the callstack when a child process crashes. |
75 IN_PROC_BROWSER_TEST_F(ContentBrowserTest, RendererCrashCallStack) { | 71 IN_PROC_BROWSER_TEST_F(ContentBrowserTest, RendererCrashCallStack) { |
76 #if defined(OS_WIN) | |
77 // Matches the same condition in RouteStdioToConsole, which makes this test | |
78 // fail on XP. | |
79 if (base::win::GetVersion() < base::win::VERSION_VISTA) | |
80 return; | |
81 #endif | |
82 | |
83 base::ThreadRestrictions::ScopedAllowIO allow_io_for_temp_dir; | 72 base::ThreadRestrictions::ScopedAllowIO allow_io_for_temp_dir; |
84 base::ScopedTempDir temp_dir; | 73 base::ScopedTempDir temp_dir; |
85 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 74 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
86 base::CommandLine new_test = | 75 base::CommandLine new_test = |
87 base::CommandLine(base::CommandLine::ForCurrentProcess()->GetProgram()); | 76 base::CommandLine(base::CommandLine::ForCurrentProcess()->GetProgram()); |
88 new_test.AppendSwitchASCII(base::kGTestFilterFlag, | 77 new_test.AppendSwitchASCII(base::kGTestFilterFlag, |
89 "ContentBrowserTest.MANUAL_RendererCrash"); | 78 "ContentBrowserTest.MANUAL_RendererCrash"); |
90 new_test.AppendSwitch(kRunManualTestsFlag); | 79 new_test.AppendSwitch(kRunManualTestsFlag); |
91 new_test.AppendSwitch(kSingleProcessTestsFlag); | 80 new_test.AppendSwitch(kSingleProcessTestsFlag); |
92 | 81 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 | 172 |
184 IN_PROC_BROWSER_TEST_F(ContentBrowserTest, NonNestableTask) { | 173 IN_PROC_BROWSER_TEST_F(ContentBrowserTest, NonNestableTask) { |
185 bool non_nested_task_ran = false; | 174 bool non_nested_task_ran = false; |
186 base::ThreadTaskRunnerHandle::Get()->PostNonNestableTask( | 175 base::ThreadTaskRunnerHandle::Get()->PostNonNestableTask( |
187 FROM_HERE, base::Bind(&CallbackChecker, &non_nested_task_ran)); | 176 FROM_HERE, base::Bind(&CallbackChecker, &non_nested_task_ran)); |
188 content::RunAllPendingInMessageLoop(); | 177 content::RunAllPendingInMessageLoop(); |
189 ASSERT_TRUE(non_nested_task_ran); | 178 ASSERT_TRUE(non_nested_task_ran); |
190 } | 179 } |
191 | 180 |
192 } // namespace content | 181 } // namespace content |
OLD | NEW |