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) | 28 #if defined(OS_WIN) |
29 #include "base/win/windows_version.h" | 29 #include "base/win/windows_version.h" |
sky
2016/08/02 16:34:46
If you can, remove this.
scottmg
2016/08/02 19:15:30
Done.
| |
30 #endif | 30 #endif |
31 | 31 |
32 namespace content { | 32 namespace content { |
33 | 33 |
34 // Disabled on official builds because symbolization in sandboxes processes | 34 // Disabled on official builds because symbolization in sandboxes processes |
35 // opens up security holes. | 35 // opens up security holes. |
36 // On Android symbolization happens in one step after all the tests ran, so this | 36 // On Android symbolization happens in one step after all the tests ran, so this |
37 // test doesn't work there. | 37 // test doesn't work there. |
38 // TODO(mac): figure out why symbolization doesn't happen in the renderer. | 38 // TODO(mac): figure out why symbolization doesn't happen in the renderer. |
39 // http://crbug.com/521456 | 39 // http://crbug.com/521456 |
(...skipping 26 matching lines...) Expand all Loading... | |
66 scoped_refptr<MessageLoopRunner> message_loop_runner = new MessageLoopRunner; | 66 scoped_refptr<MessageLoopRunner> message_loop_runner = new MessageLoopRunner; |
67 CrashObserver crash_observer(message_loop_runner->QuitClosure()); | 67 CrashObserver crash_observer(message_loop_runner->QuitClosure()); |
68 shell()->web_contents()->GetRenderProcessHost()->AddObserver(&crash_observer); | 68 shell()->web_contents()->GetRenderProcessHost()->AddObserver(&crash_observer); |
69 | 69 |
70 NavigateToURL(shell(), GURL("chrome:crash")); | 70 NavigateToURL(shell(), GURL("chrome:crash")); |
71 message_loop_runner->Run(); | 71 message_loop_runner->Run(); |
72 } | 72 } |
73 | 73 |
74 // Tests that browser tests print the callstack when a child process crashes. | 74 // Tests that browser tests print the callstack when a child process crashes. |
75 IN_PROC_BROWSER_TEST_F(ContentBrowserTest, RendererCrashCallStack) { | 75 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; | 76 base::ThreadRestrictions::ScopedAllowIO allow_io_for_temp_dir; |
84 base::ScopedTempDir temp_dir; | 77 base::ScopedTempDir temp_dir; |
85 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 78 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
86 base::CommandLine new_test = | 79 base::CommandLine new_test = |
87 base::CommandLine(base::CommandLine::ForCurrentProcess()->GetProgram()); | 80 base::CommandLine(base::CommandLine::ForCurrentProcess()->GetProgram()); |
88 new_test.AppendSwitchASCII(base::kGTestFilterFlag, | 81 new_test.AppendSwitchASCII(base::kGTestFilterFlag, |
89 "ContentBrowserTest.MANUAL_RendererCrash"); | 82 "ContentBrowserTest.MANUAL_RendererCrash"); |
90 new_test.AppendSwitch(kRunManualTestsFlag); | 83 new_test.AppendSwitch(kRunManualTestsFlag); |
91 new_test.AppendSwitch(kSingleProcessTestsFlag); | 84 new_test.AppendSwitch(kSingleProcessTestsFlag); |
92 | 85 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
183 | 176 |
184 IN_PROC_BROWSER_TEST_F(ContentBrowserTest, NonNestableTask) { | 177 IN_PROC_BROWSER_TEST_F(ContentBrowserTest, NonNestableTask) { |
185 bool non_nested_task_ran = false; | 178 bool non_nested_task_ran = false; |
186 base::ThreadTaskRunnerHandle::Get()->PostNonNestableTask( | 179 base::ThreadTaskRunnerHandle::Get()->PostNonNestableTask( |
187 FROM_HERE, base::Bind(&CallbackChecker, &non_nested_task_ran)); | 180 FROM_HERE, base::Bind(&CallbackChecker, &non_nested_task_ran)); |
188 content::RunAllPendingInMessageLoop(); | 181 content::RunAllPendingInMessageLoop(); |
189 ASSERT_TRUE(non_nested_task_ran); | 182 ASSERT_TRUE(non_nested_task_ran); |
190 } | 183 } |
191 | 184 |
192 } // namespace content | 185 } // namespace content |
OLD | NEW |