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

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: 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
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 #if defined(OS_MACOSX)
710 TEST_F(GpuControlListEntryTest, MachineModelMac) {
711 const std::string json = LONG_STRING_CONST(
712 {
713 "id": 1,
714 "os": {
715 "type": "macosx"
716 },
717 "machine_model": {
718 "name": {
719 "op": "=",
720 "value": "MacBookPro"
721 },
722 "version": {
723 "op": "=",
724 "value": "7.1"
725 }
726 },
727 "features": [
728 "test_feature_0"
729 ]
730 }
731 );
732 ScopedEntry entry(GetEntryFromString(json));
733 EXPECT_TRUE(entry.get() != NULL);
734 GPUInfo gpu_info;
735 gpu_info_.machine_model = "MacBookPro 7.1";
736 EXPECT_EQ(GpuControlList::kOsMacosx, entry->GetOsType());
737 EXPECT_TRUE(entry->Contains(
738 GpuControlList::kOsMacosx, "10.6", gpu_info));
739 }
740 #else
741 TEST_F(GpuControlListEntryTest, MachineModelNonMac) {
742 const std::string json = LONG_STRING_CONST(
743 {
744 "id": 1,
745 "os": {
746 "type": "android"
747 },
748 "machine_model": {
749 "name": {
750 "op": "=",
751 "value": "Nexus 5"
752 }
753 },
754 "features": [
755 "test_feature_0"
756 ]
757 }
758 );
759 ScopedEntry entry(GetEntryFromString(json));
760 EXPECT_TRUE(entry.get() != NULL);
761 EXPECT_EQ(GpuControlList::kOsAndroid, entry->GetOsType());
762 GPUInfo gpu_info;
763 gpu_info.machine_model = "Nexus 5";
764 EXPECT_TRUE(entry->Contains(
765 GpuControlList::kOsAndroid, "4.1", gpu_info));
766 }
767 #endif
768
710 class GpuControlListEntryDualGPUTest : public GpuControlListEntryTest { 769 class GpuControlListEntryDualGPUTest : public GpuControlListEntryTest {
711 public: 770 public:
712 GpuControlListEntryDualGPUTest() { } 771 GpuControlListEntryDualGPUTest() { }
713 virtual ~GpuControlListEntryDualGPUTest() { } 772 virtual ~GpuControlListEntryDualGPUTest() { }
714 773
715 virtual void SetUp() OVERRIDE { 774 virtual void SetUp() OVERRIDE {
716 // Set up a NVIDIA/Intel dual, with NVIDIA as primary and Intel as 775 // Set up a NVIDIA/Intel dual, with NVIDIA as primary and Intel as
717 // secondary, and initially Intel is active. 776 // secondary, and initially Intel is active.
718 gpu_info_.gpu.vendor_id = 0x10de; 777 gpu_info_.gpu.vendor_id = 0x10de;
719 gpu_info_.gpu.device_id = 0x0640; 778 gpu_info_.gpu.device_id = 0x0640;
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 ); 971 );
913 // By default, secondary GPU is active. 972 // By default, secondary GPU is active.
914 EntryShouldNotApply(json); 973 EntryShouldNotApply(json);
915 974
916 ActivatePrimaryGPU(); 975 ActivatePrimaryGPU();
917 EntryShouldApply(json); 976 EntryShouldApply(json);
918 } 977 }
919 978
920 } // namespace gpu 979 } // namespace gpu
921 980
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698