Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Side by Side Diff: content/browser/gpu/gpu_driver_bug_list_unittest.cc

Issue 15094006: Change gpu blacklists from json resource to const string. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 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/base_paths.h"
6 #include "base/file_util.h"
7 #include "base/files/file_path.h"
8 #include "base/logging.h" 5 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
10 #include "base/path_service.h" 7 #include "content/browser/gpu/gpu_control_list_jsons.h"
11 #include "content/browser/gpu/gpu_driver_bug_list.h" 8 #include "content/browser/gpu/gpu_driver_bug_list.h"
12 #include "content/public/common/gpu_info.h" 9 #include "content/public/common/gpu_info.h"
13 #include "gpu/command_buffer/service/gpu_driver_bug_workaround_type.h" 10 #include "gpu/command_buffer/service/gpu_driver_bug_workaround_type.h"
14 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
15 12
16 const char kOsVersion[] = "10.6.4"; 13 const char kOsVersion[] = "10.6.4";
17 14
18 namespace content { 15 namespace content {
19 16
20 class GpuDriverBugListTest : public testing::Test { 17 class GpuDriverBugListTest : public testing::Test {
21 public: 18 public:
22 GpuDriverBugListTest() { } 19 GpuDriverBugListTest() { }
23 20
24 virtual ~GpuDriverBugListTest() { } 21 virtual ~GpuDriverBugListTest() { }
25 22
26 const GPUInfo& gpu_info() const { 23 const GPUInfo& gpu_info() const {
27 return gpu_info_; 24 return gpu_info_;
28 } 25 }
29 26
30 bool GetCurrentDriverBugList(std::string* json) {
31 DCHECK(json);
32 base::FilePath data_file;
33 if (!PathService::Get(base::DIR_SOURCE_ROOT, &data_file))
34 return false;
35 data_file =
36 data_file.Append(FILE_PATH_LITERAL("content"))
37 .Append(FILE_PATH_LITERAL("browser"))
38 .Append(FILE_PATH_LITERAL("gpu"))
39 .Append(FILE_PATH_LITERAL("gpu_driver_bug_list.json"));
40 if (!file_util::PathExists(data_file))
41 return false;
42 int64 data_file_size64 = 0;
43 if (!file_util::GetFileSize(data_file, &data_file_size64))
44 return false;
45 int data_file_size = static_cast<int>(data_file_size64);
46 scoped_ptr<char[]> data(new char[data_file_size]);
47 if (file_util::ReadFile(data_file, data.get(), data_file_size) !=
48 data_file_size)
49 return false;
50 *json = std::string(data.get(), data_file_size);
51 return true;
52 }
53
54 protected: 27 protected:
55 virtual void SetUp() { 28 virtual void SetUp() {
56 gpu_info_.gpu.vendor_id = 0x10de; 29 gpu_info_.gpu.vendor_id = 0x10de;
57 gpu_info_.gpu.device_id = 0x0640; 30 gpu_info_.gpu.device_id = 0x0640;
58 gpu_info_.driver_vendor = "NVIDIA"; 31 gpu_info_.driver_vendor = "NVIDIA";
59 gpu_info_.driver_version = "1.6.18"; 32 gpu_info_.driver_version = "1.6.18";
60 gpu_info_.driver_date = "7-14-2009"; 33 gpu_info_.driver_date = "7-14-2009";
61 gpu_info_.machine_model = "MacBookPro 7.1"; 34 gpu_info_.machine_model = "MacBookPro 7.1";
62 gpu_info_.gl_vendor = "NVIDIA Corporation"; 35 gpu_info_.gl_vendor = "NVIDIA Corporation";
63 gpu_info_.gl_renderer = "NVIDIA GeForce GT 120 OpenGL Engine"; 36 gpu_info_.gl_renderer = "NVIDIA GeForce GT 120 OpenGL Engine";
64 gpu_info_.performance_stats.graphics = 5.0; 37 gpu_info_.performance_stats.graphics = 5.0;
65 gpu_info_.performance_stats.gaming = 5.0; 38 gpu_info_.performance_stats.gaming = 5.0;
66 gpu_info_.performance_stats.overall = 5.0; 39 gpu_info_.performance_stats.overall = 5.0;
67 } 40 }
68 41
69 virtual void TearDown() { 42 virtual void TearDown() {
70 } 43 }
71 44
72 private: 45 private:
73 GPUInfo gpu_info_; 46 GPUInfo gpu_info_;
74 }; 47 };
75 48
76 TEST_F(GpuDriverBugListTest, CurrentDriverBugListValidation) { 49 TEST_F(GpuDriverBugListTest, CurrentDriverBugListValidation) {
77 scoped_ptr<GpuDriverBugList> list(GpuDriverBugList::Create()); 50 scoped_ptr<GpuDriverBugList> list(GpuDriverBugList::Create());
78 std::string json; 51 std::string json;
79 EXPECT_TRUE(GetCurrentDriverBugList(&json)); 52 EXPECT_TRUE(list->LoadList(kGpuDriverBugListJson, GpuControlList::kAllOs));
80 EXPECT_TRUE(list->LoadList(json, GpuControlList::kAllOs));
81 EXPECT_FALSE(list->contains_unknown_fields()); 53 EXPECT_FALSE(list->contains_unknown_fields());
82 } 54 }
83 55
84 TEST_F(GpuDriverBugListTest, CurrentListForARM) { 56 TEST_F(GpuDriverBugListTest, CurrentListForARM) {
85 scoped_ptr<GpuDriverBugList> list(GpuDriverBugList::Create()); 57 scoped_ptr<GpuDriverBugList> list(GpuDriverBugList::Create());
86 std::string json; 58 EXPECT_TRUE(list->LoadList(kGpuDriverBugListJson, GpuControlList::kAllOs));
87 EXPECT_TRUE(GetCurrentDriverBugList(&json));
88 EXPECT_TRUE(list->LoadList(json, GpuControlList::kAllOs));
89 59
90 GPUInfo gpu_info; 60 GPUInfo gpu_info;
91 gpu_info.gl_vendor = "ARM"; 61 gpu_info.gl_vendor = "ARM";
92 gpu_info.gl_renderer = "MALi_T604"; 62 gpu_info.gl_renderer = "MALi_T604";
93 std::set<int> bugs = list->MakeDecision( 63 std::set<int> bugs = list->MakeDecision(
94 GpuControlList::kOsAndroid, "4.1", gpu_info); 64 GpuControlList::kOsAndroid, "4.1", gpu_info);
95 EXPECT_EQ(1u, bugs.count(gpu::USE_CLIENT_SIDE_ARRAYS_FOR_STREAM_BUFFERS)); 65 EXPECT_EQ(1u, bugs.count(gpu::USE_CLIENT_SIDE_ARRAYS_FOR_STREAM_BUFFERS));
96 } 66 }
97 67
98 TEST_F(GpuDriverBugListTest, CurrentListForImagination) { 68 TEST_F(GpuDriverBugListTest, CurrentListForImagination) {
99 scoped_ptr<GpuDriverBugList> list(GpuDriverBugList::Create()); 69 scoped_ptr<GpuDriverBugList> list(GpuDriverBugList::Create());
100 std::string json; 70 EXPECT_TRUE(list->LoadList(kGpuDriverBugListJson, GpuControlList::kAllOs));
101 EXPECT_TRUE(GetCurrentDriverBugList(&json));
102 EXPECT_TRUE(list->LoadList(json, GpuControlList::kAllOs));
103 71
104 GPUInfo gpu_info; 72 GPUInfo gpu_info;
105 gpu_info.gl_vendor = "Imagination Technologies"; 73 gpu_info.gl_vendor = "Imagination Technologies";
106 gpu_info.gl_renderer = "PowerVR SGX 540"; 74 gpu_info.gl_renderer = "PowerVR SGX 540";
107 std::set<int> bugs = list->MakeDecision( 75 std::set<int> bugs = list->MakeDecision(
108 GpuControlList::kOsAndroid, "4.1", gpu_info); 76 GpuControlList::kOsAndroid, "4.1", gpu_info);
109 EXPECT_EQ(1u, bugs.count(gpu::USE_CLIENT_SIDE_ARRAYS_FOR_STREAM_BUFFERS)); 77 EXPECT_EQ(1u, bugs.count(gpu::USE_CLIENT_SIDE_ARRAYS_FOR_STREAM_BUFFERS));
110 } 78 }
111 79
112 } // namespace content 80 } // namespace content
113 81
OLDNEW
« no previous file with comments | « content/browser/gpu/gpu_driver_bug_list_json.cc ('k') | content/browser/gpu/gpu_switching_list.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698