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

Side by Side Diff: gpu/config/gpu_control_list_entry_unittest.cc

Issue 253883006: Missing machine model info should be a no match for GPU blacklist (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « gpu/config/gpu_control_list.cc ('k') | gpu/config/software_rendering_list_json.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/json/json_reader.h" 5 #include "base/json/json_reader.h"
6 #include "gpu/config/gpu_control_list.h" 6 #include "gpu/config/gpu_control_list.h"
7 #include "gpu/config/gpu_info.h" 7 #include "gpu/config/gpu_info.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 #define LONG_STRING_CONST(...) #__VA_ARGS__ 10 #define LONG_STRING_CONST(...) #__VA_ARGS__
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 EXPECT_FALSE(entry->Contains( 736 EXPECT_FALSE(entry->Contains(
737 GpuControlList::kOsAndroid, "4.1", gpu_info)); 737 GpuControlList::kOsAndroid, "4.1", gpu_info));
738 738
739 gpu_info.machine_model_name = "Nexus 5"; 739 gpu_info.machine_model_name = "Nexus 5";
740 EXPECT_FALSE(entry->Contains( 740 EXPECT_FALSE(entry->Contains(
741 GpuControlList::kOsAndroid, "4.1", gpu_info)); 741 GpuControlList::kOsAndroid, "4.1", gpu_info));
742 742
743 gpu_info.machine_model_name = "Nexus"; 743 gpu_info.machine_model_name = "Nexus";
744 EXPECT_FALSE(entry->Contains( 744 EXPECT_FALSE(entry->Contains(
745 GpuControlList::kOsAndroid, "4.1", gpu_info)); 745 GpuControlList::kOsAndroid, "4.1", gpu_info));
746
747 gpu_info.machine_model_name = "";
748 EXPECT_FALSE(entry->Contains(
749 GpuControlList::kOsAndroid, "4.1", gpu_info));
746 } 750 }
747 751
752 TEST_F(GpuControlListEntryTest, MachineModelNameException) {
753 const std::string json = LONG_STRING_CONST(
754 {
755 "id": 1,
756 "exceptions": [
757 {
758 "os": {
759 "type": "android"
760 },
761 "machine_model_name": ["Nexus 4"]
762 }
763 ],
764 "features": [
765 "test_feature_0"
766 ]
767 }
768 );
769 ScopedEntry entry(GetEntryFromString(json));
770 EXPECT_TRUE(entry.get() != NULL);
771 EXPECT_EQ(GpuControlList::kOsAny, entry->GetOsType());
772 GPUInfo gpu_info;
773
774 gpu_info.machine_model_name = "Nexus 4";
775 EXPECT_FALSE(entry->Contains(
776 GpuControlList::kOsAndroid, "4.1", gpu_info));
777 EXPECT_TRUE(entry->Contains(
778 GpuControlList::kOsLinux, "4.1", gpu_info));
779
780 gpu_info.machine_model_name = "";
781 EXPECT_TRUE(entry->Contains(
782 GpuControlList::kOsAndroid, "4.1", gpu_info));
783 EXPECT_TRUE(entry->Contains(
784 GpuControlList::kOsLinux, "4.1", gpu_info));
785 }
786
748 TEST_F(GpuControlListEntryTest, MachineModelVersion) { 787 TEST_F(GpuControlListEntryTest, MachineModelVersion) {
749 const std::string json = LONG_STRING_CONST( 788 const std::string json = LONG_STRING_CONST(
750 { 789 {
751 "id": 1, 790 "id": 1,
752 "os": { 791 "os": {
753 "type": "macosx" 792 "type": "macosx"
754 }, 793 },
755 "machine_model_name": ["MacBookPro"], 794 "machine_model_name": ["MacBookPro"],
756 "machine_model_version": { 795 "machine_model_version": {
757 "op": "=", 796 "op": "=",
758 "value": "7.1" 797 "value": "7.1"
759 }, 798 },
760 "features": [ 799 "features": [
761 "test_feature_0" 800 "test_feature_0"
762 ] 801 ]
763 } 802 }
764 ); 803 );
765 ScopedEntry entry(GetEntryFromString(json)); 804 ScopedEntry entry(GetEntryFromString(json));
766 EXPECT_TRUE(entry.get() != NULL); 805 EXPECT_TRUE(entry.get() != NULL);
767 GPUInfo gpu_info; 806 GPUInfo gpu_info;
768 gpu_info.machine_model_name = "MacBookPro"; 807 gpu_info.machine_model_name = "MacBookPro";
769 gpu_info.machine_model_version = "7.1"; 808 gpu_info.machine_model_version = "7.1";
770 EXPECT_EQ(GpuControlList::kOsMacosx, entry->GetOsType()); 809 EXPECT_EQ(GpuControlList::kOsMacosx, entry->GetOsType());
771 EXPECT_TRUE(entry->Contains( 810 EXPECT_TRUE(entry->Contains(
772 GpuControlList::kOsMacosx, "10.6", gpu_info)); 811 GpuControlList::kOsMacosx, "10.6", gpu_info));
773 } 812 }
774 813
814 TEST_F(GpuControlListEntryTest, MachineModelVersionException) {
815 const std::string json = LONG_STRING_CONST(
816 {
817 "id": 1,
818 "os": {
819 "type": "macosx"
820 },
821 "machine_model_name": ["MacBookPro"],
822 "exceptions": [
823 {
824 "machine_model_version": {
825 "op": ">",
826 "value": "7.1"
827 }
828 }
829 ],
830 "features": [
831 "test_feature_0"
832 ]
833 }
834 );
835 ScopedEntry entry(GetEntryFromString(json));
836 EXPECT_TRUE(entry.get() != NULL);
837 EXPECT_EQ(GpuControlList::kOsMacosx, entry->GetOsType());
838
839 GPUInfo gpu_info;
840 gpu_info.machine_model_name = "MacBookPro";
841 gpu_info.machine_model_version = "7.0";
842 EXPECT_TRUE(entry->Contains(
843 GpuControlList::kOsMacosx, "10.6", gpu_info));
844
845 gpu_info.machine_model_version = "7.2";
846 EXPECT_FALSE(entry->Contains(
847 GpuControlList::kOsMacosx, "10.6", gpu_info));
848
849 gpu_info.machine_model_version = "";
850 EXPECT_TRUE(entry->Contains(
851 GpuControlList::kOsMacosx, "10.6", gpu_info));
852 }
853
775 class GpuControlListEntryDualGPUTest : public GpuControlListEntryTest { 854 class GpuControlListEntryDualGPUTest : public GpuControlListEntryTest {
776 public: 855 public:
777 GpuControlListEntryDualGPUTest() { } 856 GpuControlListEntryDualGPUTest() { }
778 virtual ~GpuControlListEntryDualGPUTest() { } 857 virtual ~GpuControlListEntryDualGPUTest() { }
779 858
780 virtual void SetUp() OVERRIDE { 859 virtual void SetUp() OVERRIDE {
781 // Set up a NVIDIA/Intel dual, with NVIDIA as primary and Intel as 860 // Set up a NVIDIA/Intel dual, with NVIDIA as primary and Intel as
782 // secondary, and initially Intel is active. 861 // secondary, and initially Intel is active.
783 gpu_info_.gpu.vendor_id = 0x10de; 862 gpu_info_.gpu.vendor_id = 0x10de;
784 gpu_info_.gpu.device_id = 0x0640; 863 gpu_info_.gpu.device_id = 0x0640;
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 ); 1056 );
978 // By default, secondary GPU is active. 1057 // By default, secondary GPU is active.
979 EntryShouldNotApply(json); 1058 EntryShouldNotApply(json);
980 1059
981 ActivatePrimaryGPU(); 1060 ActivatePrimaryGPU();
982 EntryShouldApply(json); 1061 EntryShouldApply(json);
983 } 1062 }
984 1063
985 } // namespace gpu 1064 } // namespace gpu
986 1065
OLDNEW
« no previous file with comments | « gpu/config/gpu_control_list.cc ('k') | gpu/config/software_rendering_list_json.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698