| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "base/command_line.h" | |
| 6 #include "base/memory/scoped_ptr.h" | |
| 7 #include "base/path_service.h" | 5 #include "base/path_service.h" |
| 8 #include "base/utf_string_conversions.h" | 6 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 7 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
| 9 #include "content/public/browser/notification_service.h" | 8 #include "content/public/browser/notification_service.h" |
| 10 #include "content/public/browser/notification_types.h" | 9 #include "content/public/browser/notification_types.h" |
| 11 #include "content/public/common/content_paths.h" | 10 #include "content/public/common/content_paths.h" |
| 12 #include "content/public/common/url_constants.h" | |
| 13 #include "content/public/test/browser_test_utils.h" | 11 #include "content/public/test/browser_test_utils.h" |
| 14 #include "content/public/test/test_utils.h" | 12 #include "content/public/test/test_utils.h" |
| 15 #include "content/shell/shell.h" | 13 #include "content/shell/shell.h" |
| 16 #include "content/test/content_browser_test.h" | 14 #include "content/test/content_browser_test.h" |
| 17 #include "content/test/content_browser_test_utils.h" | 15 #include "content/test/content_browser_test_utils.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | |
| 19 #include "ui/gl/gl_implementation.h" | |
| 20 | |
| 21 namespace { | |
| 22 | |
| 23 void SimulateGPUCrash(content::Shell* s) { | |
| 24 LOG(ERROR) << "SimulateGPUCrash, before LoadURL"; | |
| 25 s->LoadURL(GURL(chrome::kChromeUIGpuCrashURL)); | |
| 26 LOG(ERROR) << "SimulateGPUCrash, after LoadURL"; | |
| 27 } | |
| 28 | |
| 29 } // namespace | |
| 30 | 16 |
| 31 namespace content { | 17 namespace content { |
| 32 class GPUCrashTest : public ContentBrowserTest { | 18 class GpuCrashTest : public ContentBrowserTest { |
| 33 protected: | 19 protected: |
| 34 virtual void SetUpCommandLine(CommandLine* command_line) { | |
| 35 // GPU tests require gpu acceleration. | |
| 36 // We do not care which GL backend is used. | |
| 37 command_line->AppendSwitchASCII(switches::kUseGL, "any"); | |
| 38 } | |
| 39 virtual void SetUpInProcessBrowserTestFixture() { | 20 virtual void SetUpInProcessBrowserTestFixture() { |
| 40 FilePath test_dir; | 21 FilePath test_dir; |
| 41 ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &test_dir)); | 22 ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &test_dir)); |
| 42 gpu_test_dir_ = test_dir.AppendASCII("gpu"); | 23 gpu_test_dir_ = test_dir.AppendASCII("gpu"); |
| 43 } | 24 } |
| 44 FilePath gpu_test_dir_; | 25 FilePath gpu_test_dir_; |
| 45 }; | 26 }; |
| 46 | 27 |
| 47 // Currently Kill times out on GPU bots: http://crbug.com/101513 | 28 IN_PROC_BROWSER_TEST_F(GpuCrashTest, MANUAL_Kill) { |
| 48 IN_PROC_BROWSER_TEST_F(GPUCrashTest, MANUAL_Kill) { | |
| 49 DOMMessageQueue message_queue; | 29 DOMMessageQueue message_queue; |
| 50 | 30 |
| 31 content::GpuDataManagerImpl::GetInstance()-> |
| 32 DisableDomainBlockingFor3DAPIsForTesting(); |
| 33 |
| 51 // Load page and wait for it to load. | 34 // Load page and wait for it to load. |
| 52 content::WindowedNotificationObserver observer( | 35 content::WindowedNotificationObserver observer( |
| 53 content::NOTIFICATION_LOAD_STOP, | 36 content::NOTIFICATION_LOAD_STOP, |
| 54 content::NotificationService::AllSources()); | 37 content::NotificationService::AllSources()); |
| 55 NavigateToURL( | 38 NavigateToURL( |
| 56 shell(), | 39 shell(), |
| 57 GetFileUrlWithQuery( | 40 GetFileUrlWithQuery( |
| 58 gpu_test_dir_.AppendASCII("webgl.html"), "query=kill")); | 41 gpu_test_dir_.AppendASCII("webgl.html"), "query=kill")); |
| 59 observer.Wait(); | 42 observer.Wait(); |
| 60 | 43 |
| 61 scoped_ptr<Shell> shell(CreateBrowser()); | 44 GpuProcessHostUIShim* host = |
| 62 SimulateGPUCrash(shell.get()); | 45 GpuProcessHostUIShim::GetOneInstance(); |
| 46 ASSERT_TRUE(host); |
| 47 host->SimulateCrash(); |
| 63 | 48 |
| 64 std::string m; | 49 std::string m; |
| 65 ASSERT_TRUE(message_queue.WaitForMessage(&m)); | 50 ASSERT_TRUE(message_queue.WaitForMessage(&m)); |
| 66 EXPECT_EQ("\"SUCCESS\"", m); | 51 EXPECT_EQ("\"SUCCESS\"", m); |
| 67 } | 52 } |
| 68 | 53 |
| 69 | 54 IN_PROC_BROWSER_TEST_F(GpuCrashTest, MANUAL_WebkitLoseContext) { |
| 70 IN_PROC_BROWSER_TEST_F(GPUCrashTest, MANUAL_WebkitLoseContext) { | |
| 71 DOMMessageQueue message_queue; | 55 DOMMessageQueue message_queue; |
| 72 | 56 |
| 73 NavigateToURL( | 57 NavigateToURL( |
| 74 shell(), | 58 shell(), |
| 75 GetFileUrlWithQuery( | 59 GetFileUrlWithQuery( |
| 76 gpu_test_dir_.AppendASCII("webgl.html"), | 60 gpu_test_dir_.AppendASCII("webgl.html"), |
| 77 "query=WEBGL_lose_context")); | 61 "query=WEBGL_lose_context")); |
| 78 | 62 |
| 79 std::string m; | 63 std::string m; |
| 80 ASSERT_TRUE(message_queue.WaitForMessage(&m)); | 64 ASSERT_TRUE(message_queue.WaitForMessage(&m)); |
| 81 EXPECT_EQ("\"SUCCESS\"", m); | 65 EXPECT_EQ("\"SUCCESS\"", m); |
| 82 } | 66 } |
| 83 | 67 |
| 84 } // namespace content | 68 } // namespace content |
| OLD | NEW |