Home | History | Annotate | Download | only in config
      1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "base/logging.h"
      6 #include "base/memory/scoped_ptr.h"
      7 #include "gpu/config/gpu_control_list_jsons.h"
      8 #include "gpu/config/gpu_driver_bug_list.h"
      9 #include "gpu/config/gpu_driver_bug_workaround_type.h"
     10 #include "gpu/config/gpu_info.h"
     11 #include "testing/gtest/include/gtest/gtest.h"
     12 
     13 const char kOsVersion[] = "10.6.4";
     14 
     15 namespace gpu {
     16 
     17 class GpuDriverBugListTest : public testing::Test {
     18  public:
     19   GpuDriverBugListTest() { }
     20 
     21   virtual ~GpuDriverBugListTest() { }
     22 
     23   const GPUInfo& gpu_info() const {
     24     return gpu_info_;
     25   }
     26 
     27  protected:
     28   virtual void SetUp() {
     29     gpu_info_.gpu.vendor_id = 0x10de;
     30     gpu_info_.gpu.device_id = 0x0640;
     31     gpu_info_.driver_vendor = "NVIDIA";
     32     gpu_info_.driver_version = "1.6.18";
     33     gpu_info_.driver_date = "7-14-2009";
     34     gpu_info_.machine_model = "MacBookPro 7.1";
     35     gpu_info_.gl_vendor = "NVIDIA Corporation";
     36     gpu_info_.gl_renderer = "NVIDIA GeForce GT 120 OpenGL Engine";
     37     gpu_info_.performance_stats.graphics = 5.0;
     38     gpu_info_.performance_stats.gaming = 5.0;
     39     gpu_info_.performance_stats.overall = 5.0;
     40   }
     41 
     42   virtual void TearDown() {
     43   }
     44 
     45  private:
     46   GPUInfo gpu_info_;
     47 };
     48 
     49 TEST_F(GpuDriverBugListTest, CurrentDriverBugListValidation) {
     50   scoped_ptr<GpuDriverBugList> list(GpuDriverBugList::Create());
     51   std::string json;
     52   EXPECT_TRUE(list->LoadList(kGpuDriverBugListJson, GpuControlList::kAllOs));
     53   EXPECT_FALSE(list->contains_unknown_fields());
     54 }
     55 
     56 TEST_F(GpuDriverBugListTest, CurrentListForARM) {
     57   scoped_ptr<GpuDriverBugList> list(GpuDriverBugList::Create());
     58   EXPECT_TRUE(list->LoadList(kGpuDriverBugListJson, GpuControlList::kAllOs));
     59 
     60   GPUInfo gpu_info;
     61   gpu_info.gl_vendor = "ARM";
     62   gpu_info.gl_renderer = "MALi_T604";
     63   std::set<int> bugs = list->MakeDecision(
     64       GpuControlList::kOsAndroid, "4.1", gpu_info);
     65   EXPECT_EQ(1u, bugs.count(USE_CLIENT_SIDE_ARRAYS_FOR_STREAM_BUFFERS));
     66 }
     67 
     68 TEST_F(GpuDriverBugListTest, CurrentListForImagination) {
     69   scoped_ptr<GpuDriverBugList> list(GpuDriverBugList::Create());
     70   EXPECT_TRUE(list->LoadList(kGpuDriverBugListJson, GpuControlList::kAllOs));
     71 
     72   GPUInfo gpu_info;
     73   gpu_info.gl_vendor = "Imagination Technologies";
     74   gpu_info.gl_renderer = "PowerVR SGX 540";
     75   std::set<int> bugs = list->MakeDecision(
     76       GpuControlList::kOsAndroid, "4.1", gpu_info);
     77   EXPECT_EQ(1u, bugs.count(USE_CLIENT_SIDE_ARRAYS_FOR_STREAM_BUFFERS));
     78 }
     79 
     80 }  // namespace gpu
     81 
     82