| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 // Invalid json input should not change the current blacklist settings. | 137 // Invalid json input should not change the current blacklist settings. |
| 138 const std::string invalid_json = "invalid"; | 138 const std::string invalid_json = "invalid"; |
| 139 | 139 |
| 140 EXPECT_FALSE(blacklist.LoadGpuBlacklist(invalid_json, GpuBlacklist::kAllOs)); | 140 EXPECT_FALSE(blacklist.LoadGpuBlacklist(invalid_json, GpuBlacklist::kAllOs)); |
| 141 flags = blacklist.DetermineGpuFeatureFlags( | 141 flags = blacklist.DetermineGpuFeatureFlags( |
| 142 GpuBlacklist::kOsMacosx, os_version.get(), gpu_info()); | 142 GpuBlacklist::kOsMacosx, os_version.get(), gpu_info()); |
| 143 EXPECT_EQ( | 143 EXPECT_EQ( |
| 144 flags.flags(), | 144 flags.flags(), |
| 145 static_cast<uint32>(GpuFeatureFlags::kGpuFeatureAcceleratedCompositing)); | 145 static_cast<uint32>(GpuFeatureFlags::kGpuFeatureAcceleratedCompositing)); |
| 146 std::vector<uint32> entries; | 146 std::vector<uint32> entries; |
| 147 bool disabled = false; |
| 147 blacklist.GetGpuFeatureFlagEntries( | 148 blacklist.GetGpuFeatureFlagEntries( |
| 148 GpuFeatureFlags::kGpuFeatureAcceleratedCompositing, entries); | 149 GpuFeatureFlags::kGpuFeatureAcceleratedCompositing, entries, disabled); |
| 149 EXPECT_EQ(entries.size(), 1u); | 150 EXPECT_EQ(entries.size(), 1u); |
| 150 EXPECT_EQ(entries[0], 5u); | 151 EXPECT_EQ(entries[0], 5u); |
| 151 blacklist.GetGpuFeatureFlagEntries( | 152 blacklist.GetGpuFeatureFlagEntries( |
| 152 GpuFeatureFlags::kGpuFeatureAll, entries); | 153 GpuFeatureFlags::kGpuFeatureAll, entries, disabled); |
| 153 EXPECT_EQ(entries.size(), 1u); | 154 EXPECT_EQ(entries.size(), 1u); |
| 154 EXPECT_EQ(entries[0], 5u); | 155 EXPECT_EQ(entries[0], 5u); |
| 155 EXPECT_EQ(blacklist.max_entry_id(), 5u); | 156 EXPECT_EQ(blacklist.max_entry_id(), 5u); |
| 156 } | 157 } |
| 157 | 158 |
| 158 TEST_F(GpuBlacklistTest, VendorOnAllOsEntry) { | 159 TEST_F(GpuBlacklistTest, VendorOnAllOsEntry) { |
| 159 // Blacklist a vendor on all OS. | 160 // Blacklist a vendor on all OS. |
| 160 const std::string vendor_json = | 161 const std::string vendor_json = |
| 161 "{\n" | 162 "{\n" |
| 162 " \"name\": \"gpu blacklist\",\n" | 163 " \"name\": \"gpu blacklist\",\n" |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 | 719 |
| 719 GpuBlacklist blacklist("1.0 unknown"); | 720 GpuBlacklist blacklist("1.0 unknown"); |
| 720 EXPECT_TRUE( | 721 EXPECT_TRUE( |
| 721 blacklist.LoadGpuBlacklist(gl_renderer_json, GpuBlacklist::kAllOs)); | 722 blacklist.LoadGpuBlacklist(gl_renderer_json, GpuBlacklist::kAllOs)); |
| 722 GpuFeatureFlags flags = blacklist.DetermineGpuFeatureFlags( | 723 GpuFeatureFlags flags = blacklist.DetermineGpuFeatureFlags( |
| 723 GpuBlacklist::kOsWin, os_version.get(), gpu_info()); | 724 GpuBlacklist::kOsWin, os_version.get(), gpu_info()); |
| 724 EXPECT_EQ(flags.flags(), | 725 EXPECT_EQ(flags.flags(), |
| 725 static_cast<uint32>(GpuFeatureFlags::kGpuFeatureWebgl)); | 726 static_cast<uint32>(GpuFeatureFlags::kGpuFeatureWebgl)); |
| 726 } | 727 } |
| 727 | 728 |
| 729 TEST_F(GpuBlacklistTest, DisabledEntry) { |
| 730 const std::string disabled_json = |
| 731 "{\n" |
| 732 " \"name\": \"gpu blacklist\",\n" |
| 733 " \"version\": \"0.1\",\n" |
| 734 " \"entries\": [\n" |
| 735 " {\n" |
| 736 " \"id\": 1,\n" |
| 737 " \"disabled\": true,\n" |
| 738 " \"blacklist\": [\n" |
| 739 " \"webgl\"\n" |
| 740 " ]\n" |
| 741 " }\n" |
| 742 " ]\n" |
| 743 "}"; |
| 744 scoped_ptr<Version> os_version(Version::GetVersionFromString("10.6.4")); |
| 745 |
| 746 GpuBlacklist blacklist("1.0 unknown"); |
| 747 EXPECT_TRUE( |
| 748 blacklist.LoadGpuBlacklist(disabled_json, GpuBlacklist::kAllOs)); |
| 749 GpuFeatureFlags flags = blacklist.DetermineGpuFeatureFlags( |
| 750 GpuBlacklist::kOsWin, os_version.get(), gpu_info()); |
| 751 EXPECT_EQ(flags.flags(), 0u); |
| 752 std::vector<uint32> flag_entries; |
| 753 bool disabled = false; |
| 754 blacklist.GetGpuFeatureFlagEntries( |
| 755 GpuFeatureFlags::kGpuFeatureAll, flag_entries, disabled); |
| 756 EXPECT_EQ(flag_entries.size(), 0u); |
| 757 disabled = true; |
| 758 blacklist.GetGpuFeatureFlagEntries( |
| 759 GpuFeatureFlags::kGpuFeatureAll, flag_entries, disabled); |
| 760 EXPECT_EQ(flag_entries.size(), 1u); |
| 761 } |
| 762 |
| OLD | NEW |