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

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

Issue 241793002: Fix machine_model behaviors in gpu blacklist. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 8 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
« no previous file with comments | « gpu/config/gpu_control_list.cc ('k') | gpu/config/gpu_control_list_format.txt » ('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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 return GetEntryFromString(json, false); 49 return GetEntryFromString(json, false);
50 } 50 }
51 51
52 virtual void SetUp() { 52 virtual void SetUp() {
53 gpu_info_.gpu.vendor_id = 0x10de; 53 gpu_info_.gpu.vendor_id = 0x10de;
54 gpu_info_.gpu.device_id = 0x0640; 54 gpu_info_.gpu.device_id = 0x0640;
55 gpu_info_.gpu.active = true; 55 gpu_info_.gpu.active = true;
56 gpu_info_.driver_vendor = "NVIDIA"; 56 gpu_info_.driver_vendor = "NVIDIA";
57 gpu_info_.driver_version = "1.6.18"; 57 gpu_info_.driver_version = "1.6.18";
58 gpu_info_.driver_date = "7-14-2009"; 58 gpu_info_.driver_date = "7-14-2009";
59 gpu_info_.machine_model = "MacBookPro 7.1";
60 gpu_info_.gl_vendor = "NVIDIA Corporation"; 59 gpu_info_.gl_vendor = "NVIDIA Corporation";
61 gpu_info_.gl_renderer = "NVIDIA GeForce GT 120 OpenGL Engine"; 60 gpu_info_.gl_renderer = "NVIDIA GeForce GT 120 OpenGL Engine";
62 gpu_info_.performance_stats.graphics = 5.0; 61 gpu_info_.performance_stats.graphics = 5.0;
63 gpu_info_.performance_stats.gaming = 5.0; 62 gpu_info_.performance_stats.gaming = 5.0;
64 gpu_info_.performance_stats.overall = 5.0; 63 gpu_info_.performance_stats.overall = 5.0;
65 } 64 }
66 65
67 protected: 66 protected:
68 GPUInfo gpu_info_; 67 GPUInfo gpu_info_;
69 }; 68 };
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 ] 699 ]
701 } 700 }
702 ); 701 );
703 ScopedEntry entry(GetEntryFromString(json)); 702 ScopedEntry entry(GetEntryFromString(json));
704 EXPECT_TRUE(entry.get() != NULL); 703 EXPECT_TRUE(entry.get() != NULL);
705 EXPECT_EQ(GpuControlList::kOsMacosx, entry->GetOsType()); 704 EXPECT_EQ(GpuControlList::kOsMacosx, entry->GetOsType());
706 EXPECT_TRUE(entry->Contains( 705 EXPECT_TRUE(entry->Contains(
707 GpuControlList::kOsMacosx, "10.6", gpu_info())); 706 GpuControlList::kOsMacosx, "10.6", gpu_info()));
708 } 707 }
709 708
709 TEST_F(GpuControlListEntryTest, MachineModelName) {
710 const std::string json = LONG_STRING_CONST(
711 {
712 "id": 1,
713 "os": {
714 "type": "android"
715 },
716 "machine_model_name": ["Nexus 4", "XT1032"],
717 "features": [
718 "test_feature_0"
719 ]
720 }
721 );
722 ScopedEntry entry(GetEntryFromString(json));
723 EXPECT_TRUE(entry.get() != NULL);
724 EXPECT_EQ(GpuControlList::kOsAndroid, entry->GetOsType());
725 GPUInfo gpu_info;
726
727 gpu_info.machine_model_name = "Nexus 4";
728 EXPECT_TRUE(entry->Contains(
729 GpuControlList::kOsAndroid, "4.1", gpu_info));
730
731 gpu_info.machine_model_name = "XT1032";
732 EXPECT_TRUE(entry->Contains(
733 GpuControlList::kOsAndroid, "4.1", gpu_info));
734
735 gpu_info.machine_model_name = "XT1032i";
736 EXPECT_FALSE(entry->Contains(
737 GpuControlList::kOsAndroid, "4.1", gpu_info));
738
739 gpu_info.machine_model_name = "Nexus 5";
740 EXPECT_FALSE(entry->Contains(
741 GpuControlList::kOsAndroid, "4.1", gpu_info));
742
743 gpu_info.machine_model_name = "Nexus";
744 EXPECT_FALSE(entry->Contains(
745 GpuControlList::kOsAndroid, "4.1", gpu_info));
746 }
747
748 TEST_F(GpuControlListEntryTest, MachineModelVersion) {
749 const std::string json = LONG_STRING_CONST(
750 {
751 "id": 1,
752 "os": {
753 "type": "macosx"
754 },
755 "machine_model_name": ["MacBookPro"],
756 "machine_model_version": {
757 "op": "=",
758 "value": "7.1"
759 },
760 "features": [
761 "test_feature_0"
762 ]
763 }
764 );
765 ScopedEntry entry(GetEntryFromString(json));
766 EXPECT_TRUE(entry.get() != NULL);
767 GPUInfo gpu_info;
768 gpu_info.machine_model_name = "MacBookPro";
769 gpu_info.machine_model_version = "7.1";
770 EXPECT_EQ(GpuControlList::kOsMacosx, entry->GetOsType());
771 EXPECT_TRUE(entry->Contains(
772 GpuControlList::kOsMacosx, "10.6", gpu_info));
773 }
774
710 class GpuControlListEntryDualGPUTest : public GpuControlListEntryTest { 775 class GpuControlListEntryDualGPUTest : public GpuControlListEntryTest {
711 public: 776 public:
712 GpuControlListEntryDualGPUTest() { } 777 GpuControlListEntryDualGPUTest() { }
713 virtual ~GpuControlListEntryDualGPUTest() { } 778 virtual ~GpuControlListEntryDualGPUTest() { }
714 779
715 virtual void SetUp() OVERRIDE { 780 virtual void SetUp() OVERRIDE {
716 // Set up a NVIDIA/Intel dual, with NVIDIA as primary and Intel as 781 // Set up a NVIDIA/Intel dual, with NVIDIA as primary and Intel as
717 // secondary, and initially Intel is active. 782 // secondary, and initially Intel is active.
718 gpu_info_.gpu.vendor_id = 0x10de; 783 gpu_info_.gpu.vendor_id = 0x10de;
719 gpu_info_.gpu.device_id = 0x0640; 784 gpu_info_.gpu.device_id = 0x0640;
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 ); 977 );
913 // By default, secondary GPU is active. 978 // By default, secondary GPU is active.
914 EntryShouldNotApply(json); 979 EntryShouldNotApply(json);
915 980
916 ActivatePrimaryGPU(); 981 ActivatePrimaryGPU();
917 EntryShouldApply(json); 982 EntryShouldApply(json);
918 } 983 }
919 984
920 } // namespace gpu 985 } // namespace gpu
921 986
OLDNEW
« no previous file with comments | « gpu/config/gpu_control_list.cc ('k') | gpu/config/gpu_control_list_format.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698