| OLD | NEW |
| 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/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/path_service.h" | |
| 10 #include "content/browser/gpu/gpu_blacklist.h" | 6 #include "content/browser/gpu/gpu_blacklist.h" |
| 7 #include "content/browser/gpu/gpu_control_list_jsons.h" |
| 11 #include "content/public/common/gpu_feature_type.h" | 8 #include "content/public/common/gpu_feature_type.h" |
| 12 #include "content/public/common/gpu_info.h" | 9 #include "content/public/common/gpu_info.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 11 |
| 15 const char kOsVersion[] = "10.6.4"; | 12 const char kOsVersion[] = "10.6.4"; |
| 16 | 13 |
| 17 namespace content { | 14 namespace content { |
| 18 | 15 |
| 19 class GpuBlacklistTest : public testing::Test { | 16 class GpuBlacklistTest : public testing::Test { |
| 20 public: | 17 public: |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 } | 70 } |
| 74 | 71 |
| 75 virtual void TearDown() { | 72 virtual void TearDown() { |
| 76 } | 73 } |
| 77 | 74 |
| 78 private: | 75 private: |
| 79 GPUInfo gpu_info_; | 76 GPUInfo gpu_info_; |
| 80 }; | 77 }; |
| 81 | 78 |
| 82 TEST_F(GpuBlacklistTest, CurrentBlacklistValidation) { | 79 TEST_F(GpuBlacklistTest, CurrentBlacklistValidation) { |
| 83 base::FilePath data_file; | |
| 84 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &data_file)); | |
| 85 data_file = | |
| 86 data_file.Append(FILE_PATH_LITERAL("content")) | |
| 87 .Append(FILE_PATH_LITERAL("browser")) | |
| 88 .Append(FILE_PATH_LITERAL("gpu")) | |
| 89 .Append(FILE_PATH_LITERAL("software_rendering_list.json")); | |
| 90 ASSERT_TRUE(file_util::PathExists(data_file)); | |
| 91 int64 data_file_size64 = 0; | |
| 92 ASSERT_TRUE(file_util::GetFileSize(data_file, &data_file_size64)); | |
| 93 int data_file_size = static_cast<int>(data_file_size64); | |
| 94 scoped_ptr<char[]> data(new char[data_file_size]); | |
| 95 ASSERT_EQ(data_file_size, | |
| 96 file_util::ReadFile(data_file, data.get(), data_file_size)); | |
| 97 std::string json_string(data.get(), data_file_size); | |
| 98 scoped_ptr<GpuBlacklist> blacklist(GpuBlacklist::Create()); | 80 scoped_ptr<GpuBlacklist> blacklist(GpuBlacklist::Create()); |
| 99 EXPECT_TRUE(blacklist->LoadList(json_string, GpuBlacklist::kAllOs)); | 81 EXPECT_TRUE(blacklist->LoadList( |
| 82 kSoftwareRenderingListJson, GpuBlacklist::kAllOs)); |
| 100 EXPECT_FALSE(blacklist->contains_unknown_fields()); | 83 EXPECT_FALSE(blacklist->contains_unknown_fields()); |
| 101 } | 84 } |
| 102 | 85 |
| 103 #define GPU_BLACKLIST_FEATURE_TEST(test_name, feature_name, feature_type) \ | 86 #define GPU_BLACKLIST_FEATURE_TEST(test_name, feature_name, feature_type) \ |
| 104 TEST_F(GpuBlacklistTest, test_name) { \ | 87 TEST_F(GpuBlacklistTest, test_name) { \ |
| 105 RunFeatureTest(feature_name, feature_type); \ | 88 RunFeatureTest(feature_name, feature_type); \ |
| 106 } | 89 } |
| 107 | 90 |
| 108 GPU_BLACKLIST_FEATURE_TEST(Accelerated2DCanvas, | 91 GPU_BLACKLIST_FEATURE_TEST(Accelerated2DCanvas, |
| 109 "accelerated_2d_canvas", | 92 "accelerated_2d_canvas", |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 134 |
| 152 GPU_BLACKLIST_FEATURE_TEST(PanelFitting, | 135 GPU_BLACKLIST_FEATURE_TEST(PanelFitting, |
| 153 "panel_fitting", | 136 "panel_fitting", |
| 154 GPU_FEATURE_TYPE_PANEL_FITTING) | 137 GPU_FEATURE_TYPE_PANEL_FITTING) |
| 155 | 138 |
| 156 GPU_BLACKLIST_FEATURE_TEST(ForceCompositingMode, | 139 GPU_BLACKLIST_FEATURE_TEST(ForceCompositingMode, |
| 157 "force_compositing_mode", | 140 "force_compositing_mode", |
| 158 GPU_FEATURE_TYPE_FORCE_COMPOSITING_MODE) | 141 GPU_FEATURE_TYPE_FORCE_COMPOSITING_MODE) |
| 159 | 142 |
| 160 } // namespace content | 143 } // namespace content |
| OLD | NEW |