| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/gfx/gl/gl_implementation.h" |
| 6 #include "base/command_line.h" |
| 5 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 6 #include "base/string16.h" | 8 #include "base/string16.h" |
| 7 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 8 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 9 #include "chrome/browser/browser.h" | 11 #include "chrome/browser/browser.h" |
| 10 #include "chrome/browser/tab_contents/tab_contents.h" | 12 #include "chrome/browser/tab_contents/tab_contents.h" |
| 11 #include "chrome/common/chrome_paths.h" | 13 #include "chrome/common/chrome_paths.h" |
| 14 #include "chrome/common/chrome_switches.h" |
| 12 #include "chrome/test/in_process_browser_test.h" | 15 #include "chrome/test/in_process_browser_test.h" |
| 16 #include "chrome/test/test_launcher_utils.h" |
| 13 #include "chrome/test/ui_test_utils.h" | 17 #include "chrome/test/ui_test_utils.h" |
| 14 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
| 15 #include "net/base/net_util.h" | 19 #include "net/base/net_util.h" |
| 16 | 20 |
| 17 class GPUBrowserTest : public InProcessBrowserTest { | 21 class GPUBrowserTest : public InProcessBrowserTest { |
| 18 protected: | 22 protected: |
| 19 GPUBrowserTest() { | 23 GPUBrowserTest() { |
| 20 } | 24 } |
| 21 | 25 |
| 22 virtual void SetUpInProcessBrowserTestFixture() { | 26 virtual void SetUpInProcessBrowserTestFixture() { |
| 23 FilePath test_dir; | 27 FilePath test_dir; |
| 24 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); | 28 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); |
| 25 gpu_test_dir_ = test_dir.AppendASCII("gpu"); | 29 gpu_test_dir_ = test_dir.AppendASCII("gpu"); |
| 26 } | 30 } |
| 27 | 31 |
| 32 virtual void SetUpCommandLine(CommandLine* command_line) { |
| 33 InProcessBrowserTest::SetUpCommandLine(command_line); |
| 34 |
| 35 EXPECT_TRUE(test_launcher_utils::OverrideGLImplementation( |
| 36 command_line, |
| 37 gfx::kGLImplementationOSMesaName)); |
| 38 |
| 39 #if defined(OS_MACOSX) |
| 40 // Accelerated compositing does not work with OSMesa. AcceleratedSurface |
| 41 // assumes GL contexts are native. |
| 42 command_line->AppendSwitch(switches::kDisableAcceleratedCompositing); |
| 43 #endif |
| 44 } |
| 45 |
| 28 FilePath gpu_test_dir_; | 46 FilePath gpu_test_dir_; |
| 29 }; | 47 }; |
| 30 | 48 |
| 31 IN_PROC_BROWSER_TEST_F(GPUBrowserTest, BrowserTestLaunchedWithOSMesa) { | 49 IN_PROC_BROWSER_TEST_F(GPUBrowserTest, BrowserTestCanLaunchWithOSMesa) { |
| 32 // Check the webgl test reports success and that the renderer was OSMesa. | 50 // Check the webgl test reports success and that the renderer was OSMesa. |
| 33 // We use OSMesa for tests in order to get consistent results across a | |
| 34 // variety of boxes. | |
| 35 ui_test_utils::NavigateToURL( | 51 ui_test_utils::NavigateToURL( |
| 36 browser(), | 52 browser(), |
| 37 net::FilePathToFileURL(gpu_test_dir_.AppendASCII("webgl.html"))); | 53 net::FilePathToFileURL(gpu_test_dir_.AppendASCII("webgl.html"))); |
| 38 | 54 |
| 39 EXPECT_EQ(ASCIIToUTF16("SUCCESS: Mesa OffScreen"), | 55 EXPECT_EQ(ASCIIToUTF16("SUCCESS: Mesa OffScreen"), |
| 40 browser()->GetSelectedTabContents()->GetTitle()); | 56 browser()->GetSelectedTabContents()->GetTitle()); |
| 41 } | 57 } |
| OLD | NEW |