diff options
Diffstat (limited to 'chrome/browser/gpu_pixel_browsertest.cc')
-rw-r--r-- | chrome/browser/gpu_pixel_browsertest.cc | 52 |
1 files changed, 18 insertions, 34 deletions
diff --git a/chrome/browser/gpu_pixel_browsertest.cc b/chrome/browser/gpu_pixel_browsertest.cc index f4a7baa..92d6134 100644 --- a/chrome/browser/gpu_pixel_browsertest.cc +++ b/chrome/browser/gpu_pixel_browsertest.cc @@ -109,25 +109,12 @@ class GpuPixelBrowserTest : public InProcessBrowserTest { // This enables DOM automation for tab contents. EnableDOMAutomation(); - // These tests by default use OSMesa. This can be changed if the |kUseGL| - // switch is explicitly set to something else or if |kUseGpuInTests| is - // present. - if (command_line->HasSwitch(switches::kUseGL)) { - using_gpu_ = command_line->GetSwitchValueASCII(switches::kUseGL) != - gfx::kGLImplementationOSMesaName; - } else if (command_line->HasSwitch(kUseGpuInTests)) { - using_gpu_ = true; - } else { - // OSMesa will be used by default. - EXPECT_TRUE(test_launcher_utils::OverrideGLImplementation( - command_line, - gfx::kGLImplementationOSMesaName)); -#if defined(OS_MACOSX) - // Accelerated compositing does not work with OSMesa. AcceleratedSurface - // assumes GL contexts are native. - command_line->AppendSwitch(switches::kDisableAcceleratedCompositing); -#endif - using_gpu_ = false; + // These tests by default use any GL implementation it can find. + // This can be changed if the |kUseGL| switch is explicitly set to + // something or if |kUseGpuInTests| is present. + if (!command_line->HasSwitch(switches::kUseGL) && + !command_line->HasSwitch(kUseGpuInTests)) { + command_line->AppendSwitchASCII(switches::kUseGL, "any"); } // Allow file access from "file://" protocol. Otherwise, test fails with // "Uncaught Error: SECURITY_ERR: DOM Exception 18." @@ -144,11 +131,6 @@ class GpuPixelBrowserTest : public InProcessBrowserTest { else generated_img_dir_ = test_data_dir_.AppendASCII("generated"); - if (using_gpu_) - reference_img_dir_ = test_data_dir_.AppendASCII("gpu_reference"); - else - reference_img_dir_ = test_data_dir_.AppendASCII("sw_reference"); - test_name_ = testing::UnitTest::GetInstance()->current_test_info()->name(); const char* test_status_prefixes[] = {"DISABLED_", "FLAKY_", "FAILS_"}; for (size_t i = 0; i < arraysize(test_status_prefixes); ++i) { @@ -172,6 +154,7 @@ class GpuPixelBrowserTest : public InProcessBrowserTest { bool CompareImages(const SkBitmap& gen_bmp, const std::string& postfix) { // Determine the name of the image. std::string img_name = test_name_; + FilePath ref_img_dir; if (postfix.length()) img_name += "_" + postfix; #if defined(OS_WIN) @@ -183,21 +166,25 @@ class GpuPixelBrowserTest : public InProcessBrowserTest { #else #error "Not implemented for this platform" #endif - if (using_gpu_) { - GPUInfo info; - if (!GetGPUInfo(&info)) { - LOG(ERROR) << "Could not get gpu info"; - return false; - } + GPUInfo info; + if (!GetGPUInfo(&info)) { + LOG(ERROR) << "Could not get gpu info"; + return false; + } + // TODO(alokp): Why do we treat Mesa differently? + bool using_gpu = info.gl_renderer.compare(0, 4, "Mesa") != 0; + if (using_gpu) { + ref_img_dir = test_data_dir_.AppendASCII("gpu_reference"); img_name = base::StringPrintf("%s_%s_%04x-%04x.png", img_name.c_str(), os_label, info.vendor_id, info.device_id); } else { + ref_img_dir = test_data_dir_.AppendASCII("sw_reference"); img_name = base::StringPrintf("%s_%s_mesa.png", img_name.c_str(), os_label); } // Read the reference image and verify the images' dimensions are equal. - FilePath ref_img_path = reference_img_dir_.AppendASCII(img_name); + FilePath ref_img_path = ref_img_dir.AppendASCII(img_name); SkBitmap ref_bmp; bool should_compare = true; if (!ReadPNGFile(ref_img_path, &ref_bmp)) { @@ -264,12 +251,9 @@ class GpuPixelBrowserTest : public InProcessBrowserTest { FilePath test_data_dir_; private: - FilePath reference_img_dir_; FilePath generated_img_dir_; // The name of the test, with any special prefixes dropped. std::string test_name_; - // Whether the gpu, or OSMesa is being used for rendering. - bool using_gpu_; DISALLOW_COPY_AND_ASSIGN(GpuPixelBrowserTest); }; |