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

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

Issue 475453002: Revert 289308 "Revert 289154 "Revert 289067 "Use RE string patte..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 4 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 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 gpu_info.gl_version = "3.0 NVIDIA-8.24.11 310.90.9b01"; 463 gpu_info.gl_version = "3.0 NVIDIA-8.24.11 310.90.9b01";
464 EXPECT_TRUE(entry->Contains(GpuControlList::kOsMacosx, "10.9", gpu_info)); 464 EXPECT_TRUE(entry->Contains(GpuControlList::kOsMacosx, "10.9", gpu_info));
465 465
466 gpu_info.gl_version = "4.0 NVIDIA-8.24.11 310.90.9b01"; 466 gpu_info.gl_version = "4.0 NVIDIA-8.24.11 310.90.9b01";
467 EXPECT_FALSE(entry->Contains(GpuControlList::kOsMacosx, "10.9", gpu_info)); 467 EXPECT_FALSE(entry->Contains(GpuControlList::kOsMacosx, "10.9", gpu_info));
468 468
469 gpu_info.gl_version = "OpenGL ES 3.0 (ANGLE 1.2.0.2450)"; 469 gpu_info.gl_version = "OpenGL ES 3.0 (ANGLE 1.2.0.2450)";
470 EXPECT_FALSE(entry->Contains(GpuControlList::kOsWin, "6.1", gpu_info)); 470 EXPECT_FALSE(entry->Contains(GpuControlList::kOsWin, "6.1", gpu_info));
471 } 471 }
472 472
473 TEST_F(GpuControlListEntryTest, GlVendorEqual) { 473 TEST_F(GpuControlListEntryTest, GlVendorEntry) {
474 const std::string json = LONG_STRING_CONST( 474 const std::string json = LONG_STRING_CONST(
475 { 475 {
476 "id": 1, 476 "id": 1,
477 "gl_vendor": "NVIDIA", 477 "gl_vendor": {
478 "op": "beginwith",
479 "value": "NVIDIA"
480 },
478 "features": [ 481 "features": [
479 "test_feature_0" 482 "test_feature_0"
480 ] 483 ]
481 } 484 }
482 ); 485 );
483 ScopedEntry entry(GetEntryFromString(json)); 486 ScopedEntry entry(GetEntryFromString(json));
484 EXPECT_TRUE(entry.get() != NULL); 487 EXPECT_TRUE(entry.get() != NULL);
485 488
486 GPUInfo gpu_info; 489 const GpuControlList::OsType os_type[] = {
487 gpu_info.gl_vendor = "NVIDIA"; 490 GpuControlList::kOsMacosx,
488 EXPECT_TRUE(entry->Contains( 491 GpuControlList::kOsWin,
489 GpuControlList::kOsMacosx, "10.9", gpu_info)); 492 GpuControlList::kOsLinux,
490 493 GpuControlList::kOsChromeOS,
491 // Case sensitive. 494 GpuControlList::kOsAndroid
492 gpu_info.gl_vendor = "NVidia"; 495 };
493 EXPECT_FALSE(entry->Contains( 496 for (size_t i = 0; i < arraysize(os_type); ++i)
494 GpuControlList::kOsMacosx, "10.9", gpu_info)); 497 EXPECT_TRUE(entry->Contains(os_type[i], "10.6", gpu_info()));
495
496 gpu_info.gl_vendor = "NVIDIA-x";
497 EXPECT_FALSE(entry->Contains(
498 GpuControlList::kOsMacosx, "10.9", gpu_info));
499 } 498 }
500 499
501 TEST_F(GpuControlListEntryTest, GlVendorWithDot) { 500 TEST_F(GpuControlListEntryTest, GlRendererEntry) {
502 const std::string json = LONG_STRING_CONST( 501 const std::string json = LONG_STRING_CONST(
503 { 502 {
504 "id": 1, 503 "id": 1,
505 "gl_vendor": "X\\.Org.*", 504 "gl_renderer": {
505 "op": "contains",
506 "value": "GeForce"
507 },
506 "features": [ 508 "features": [
507 "test_feature_0" 509 "test_feature_0"
508 ] 510 ]
509 } 511 }
510 ); 512 );
511 ScopedEntry entry(GetEntryFromString(json)); 513 ScopedEntry entry(GetEntryFromString(json));
512 EXPECT_TRUE(entry.get() != NULL); 514 EXPECT_TRUE(entry.get() != NULL);
513 515
514 GPUInfo gpu_info; 516 const GpuControlList::OsType os_type[] = {
515 gpu_info.gl_vendor = "X.Org R300 Project"; 517 GpuControlList::kOsMacosx,
516 EXPECT_TRUE(entry->Contains( 518 GpuControlList::kOsWin,
517 GpuControlList::kOsLinux, "", gpu_info)); 519 GpuControlList::kOsLinux,
518 520 GpuControlList::kOsChromeOS,
519 gpu_info.gl_vendor = "X.Org"; 521 GpuControlList::kOsAndroid
520 EXPECT_TRUE(entry->Contains( 522 };
521 GpuControlList::kOsLinux, "", gpu_info)); 523 for (size_t i = 0; i < arraysize(os_type); ++i)
522 } 524 EXPECT_TRUE(entry->Contains(os_type[i], "10.6", gpu_info()));
523
524 TEST_F(GpuControlListEntryTest, GlRendererContains) {
525 const std::string json = LONG_STRING_CONST(
526 {
527 "id": 1,
528 "gl_renderer": ".*GeForce.*",
529 "features": [
530 "test_feature_0"
531 ]
532 }
533 );
534 ScopedEntry entry(GetEntryFromString(json));
535 EXPECT_TRUE(entry.get() != NULL);
536
537 GPUInfo gpu_info;
538 gpu_info.gl_renderer = "NVIDIA GeForce GT 120 OpenGL Engine";
539 EXPECT_TRUE(entry->Contains(
540 GpuControlList::kOsMacosx, "10.9", gpu_info));
541
542 // Case sensitive.
543 gpu_info.gl_renderer = "NVIDIA GEFORCE GT 120 OpenGL Engine";
544 EXPECT_FALSE(entry->Contains(
545 GpuControlList::kOsMacosx, "10.9", gpu_info));
546
547 gpu_info.gl_renderer = "GeForce GT 120 OpenGL Engine";
548 EXPECT_TRUE(entry->Contains(
549 GpuControlList::kOsMacosx, "10.9", gpu_info));
550
551 gpu_info.gl_renderer = "NVIDIA GeForce";
552 EXPECT_TRUE(entry->Contains(
553 GpuControlList::kOsMacosx, "10.9", gpu_info));
554
555 gpu_info.gl_renderer = "NVIDIA Ge Force";
556 EXPECT_FALSE(entry->Contains(
557 GpuControlList::kOsMacosx, "10.9", gpu_info));
558 }
559
560 TEST_F(GpuControlListEntryTest, GlRendererCaseInsensitive) {
561 const std::string json = LONG_STRING_CONST(
562 {
563 "id": 1,
564 "gl_renderer": "(?i).*software.*",
565 "features": [
566 "test_feature_0"
567 ]
568 }
569 );
570 ScopedEntry entry(GetEntryFromString(json));
571 EXPECT_TRUE(entry.get() != NULL);
572
573 GPUInfo gpu_info;
574 gpu_info.gl_renderer = "software rasterizer";
575 EXPECT_TRUE(entry->Contains(
576 GpuControlList::kOsMacosx, "10.9", gpu_info));
577
578 gpu_info.gl_renderer = "Software Rasterizer";
579 EXPECT_TRUE(entry->Contains(
580 GpuControlList::kOsMacosx, "10.9", gpu_info));
581 }
582
583 TEST_F(GpuControlListEntryTest, GlExtensionsEndWith) {
584 const std::string json = LONG_STRING_CONST(
585 {
586 "id": 1,
587 "gl_extensions": ".*GL_SUN_slice_accum",
588 "features": [
589 "test_feature_0"
590 ]
591 }
592 );
593 ScopedEntry entry(GetEntryFromString(json));
594 EXPECT_TRUE(entry.get() != NULL);
595
596 GPUInfo gpu_info;
597 gpu_info.gl_extensions = "GL_SGIS_generate_mipmap "
598 "GL_SGIX_shadow "
599 "GL_SUN_slice_accum";
600 EXPECT_TRUE(entry->Contains(
601 GpuControlList::kOsMacosx, "10.9", gpu_info));
602
603 gpu_info.gl_extensions = "GL_SGIS_generate_mipmap "
604 "GL_SUN_slice_accum "
605 "GL_SGIX_shadow";
606 EXPECT_FALSE(entry->Contains(
607 GpuControlList::kOsMacosx, "10.9", gpu_info));
608 } 525 }
609 526
610 TEST_F(GpuControlListEntryTest, PerfGraphicsEntry) { 527 TEST_F(GpuControlListEntryTest, PerfGraphicsEntry) {
611 const std::string json = LONG_STRING_CONST( 528 const std::string json = LONG_STRING_CONST(
612 { 529 {
613 "id": 1, 530 "id": 1,
614 "perf_graphics": { 531 "perf_graphics": {
615 "op": "<", 532 "op": "<",
616 "value": "6.0" 533 "value": "6.0"
617 }, 534 },
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 GPUInfo gpu_info; 633 GPUInfo gpu_info;
717 gpu_info.amd_switchable = true; 634 gpu_info.amd_switchable = true;
718 635
719 ScopedEntry entry(GetEntryFromString(json)); 636 ScopedEntry entry(GetEntryFromString(json));
720 EXPECT_TRUE(entry.get() != NULL); 637 EXPECT_TRUE(entry.get() != NULL);
721 EXPECT_EQ(GpuControlList::kOsMacosx, entry->GetOsType()); 638 EXPECT_EQ(GpuControlList::kOsMacosx, entry->GetOsType());
722 EXPECT_TRUE(entry->Contains( 639 EXPECT_TRUE(entry->Contains(
723 GpuControlList::kOsMacosx, "10.6", gpu_info)); 640 GpuControlList::kOsMacosx, "10.6", gpu_info));
724 } 641 }
725 642
726 TEST_F(GpuControlListEntryTest, DriverVendorBeginWith) {
727 const std::string json = LONG_STRING_CONST(
728 {
729 "id": 1,
730 "driver_vendor": "NVIDIA.*",
731 "features": [
732 "test_feature_0"
733 ]
734 }
735 );
736 ScopedEntry entry(GetEntryFromString(json));
737 EXPECT_TRUE(entry.get() != NULL);
738
739 GPUInfo gpu_info;
740 gpu_info.driver_vendor = "NVIDIA Corporation";
741 EXPECT_TRUE(entry->Contains(
742 GpuControlList::kOsMacosx, "10.9", gpu_info));
743
744 // Case sensitive.
745 gpu_info.driver_vendor = "NVidia Corporation";
746 EXPECT_FALSE(entry->Contains(
747 GpuControlList::kOsMacosx, "10.9", gpu_info));
748
749 gpu_info.driver_vendor = "NVIDIA";
750 EXPECT_TRUE(entry->Contains(
751 GpuControlList::kOsMacosx, "10.9", gpu_info));
752
753 gpu_info.driver_vendor = "USA NVIDIA";
754 EXPECT_FALSE(entry->Contains(
755 GpuControlList::kOsMacosx, "10.9", gpu_info));
756 }
757
758 TEST_F(GpuControlListEntryTest, LexicalDriverVersionEntry) { 643 TEST_F(GpuControlListEntryTest, LexicalDriverVersionEntry) {
759 const std::string json = LONG_STRING_CONST( 644 const std::string json = LONG_STRING_CONST(
760 { 645 {
761 "id": 1, 646 "id": 1,
762 "os": { 647 "os": {
763 "type": "linux" 648 "type": "linux"
764 }, 649 },
765 "vendor_id": "0x1002", 650 "vendor_id": "0x1002",
766 "driver_version": { 651 "driver_version": {
767 "op": "=", 652 "op": "=",
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 EXPECT_FALSE(entry->NeedsMoreInfo(gpu_info)); 703 EXPECT_FALSE(entry->NeedsMoreInfo(gpu_info));
819 } 704 }
820 705
821 TEST_F(GpuControlListEntryTest, NeedsMoreInfoForExceptionsEntry) { 706 TEST_F(GpuControlListEntryTest, NeedsMoreInfoForExceptionsEntry) {
822 const std::string json = LONG_STRING_CONST( 707 const std::string json = LONG_STRING_CONST(
823 { 708 {
824 "id": 1, 709 "id": 1,
825 "vendor_id": "0x8086", 710 "vendor_id": "0x8086",
826 "exceptions": [ 711 "exceptions": [
827 { 712 {
828 "gl_renderer": ".*mesa.*" 713 "gl_renderer": {
714 "op": "contains",
715 "value": "mesa"
716 }
829 } 717 }
830 ], 718 ],
831 "features": [ 719 "features": [
832 "test_feature_1" 720 "test_feature_1"
833 ] 721 ]
834 } 722 }
835 ); 723 );
836 ScopedEntry entry(GetEntryFromString(json)); 724 ScopedEntry entry(GetEntryFromString(json));
837 EXPECT_TRUE(entry.get() != NULL); 725 EXPECT_TRUE(entry.get() != NULL);
838 726
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 GpuControlList::kOsMacosx, "10.6", gpu_info())); 800 GpuControlList::kOsMacosx, "10.6", gpu_info()));
913 } 801 }
914 802
915 TEST_F(GpuControlListEntryTest, MachineModelName) { 803 TEST_F(GpuControlListEntryTest, MachineModelName) {
916 const std::string json = LONG_STRING_CONST( 804 const std::string json = LONG_STRING_CONST(
917 { 805 {
918 "id": 1, 806 "id": 1,
919 "os": { 807 "os": {
920 "type": "android" 808 "type": "android"
921 }, 809 },
922 "machine_model_name": [ 810 "machine_model_name": ["Nexus 4", "XT1032"],
923 "Nexus 4", "XT1032", "GT-.*", "SCH-.*"
924 ],
925 "features": [ 811 "features": [
926 "test_feature_0" 812 "test_feature_0"
927 ] 813 ]
928 } 814 }
929 ); 815 );
930 ScopedEntry entry(GetEntryFromString(json)); 816 ScopedEntry entry(GetEntryFromString(json));
931 EXPECT_TRUE(entry.get() != NULL); 817 EXPECT_TRUE(entry.get() != NULL);
932 EXPECT_EQ(GpuControlList::kOsAndroid, entry->GetOsType()); 818 EXPECT_EQ(GpuControlList::kOsAndroid, entry->GetOsType());
933 GPUInfo gpu_info; 819 GPUInfo gpu_info;
934 820
(...skipping 13 matching lines...) Expand all
948 EXPECT_FALSE(entry->Contains( 834 EXPECT_FALSE(entry->Contains(
949 GpuControlList::kOsAndroid, "4.1", gpu_info)); 835 GpuControlList::kOsAndroid, "4.1", gpu_info));
950 836
951 gpu_info.machine_model_name = "Nexus"; 837 gpu_info.machine_model_name = "Nexus";
952 EXPECT_FALSE(entry->Contains( 838 EXPECT_FALSE(entry->Contains(
953 GpuControlList::kOsAndroid, "4.1", gpu_info)); 839 GpuControlList::kOsAndroid, "4.1", gpu_info));
954 840
955 gpu_info.machine_model_name = ""; 841 gpu_info.machine_model_name = "";
956 EXPECT_FALSE(entry->Contains( 842 EXPECT_FALSE(entry->Contains(
957 GpuControlList::kOsAndroid, "4.1", gpu_info)); 843 GpuControlList::kOsAndroid, "4.1", gpu_info));
958
959 gpu_info.machine_model_name = "GT-N7100";
960 EXPECT_TRUE(entry->Contains(
961 GpuControlList::kOsAndroid, "4.1", gpu_info));
962
963 gpu_info.machine_model_name = "GT-I9300";
964 EXPECT_TRUE(entry->Contains(
965 GpuControlList::kOsAndroid, "4.1", gpu_info));
966
967 gpu_info.machine_model_name = "SCH-I545";
968 EXPECT_TRUE(entry->Contains(
969 GpuControlList::kOsAndroid, "4.1", gpu_info));
970 } 844 }
971 845
972 TEST_F(GpuControlListEntryTest, MachineModelNameException) { 846 TEST_F(GpuControlListEntryTest, MachineModelNameException) {
973 const std::string json = LONG_STRING_CONST( 847 const std::string json = LONG_STRING_CONST(
974 { 848 {
975 "id": 1, 849 "id": 1,
976 "exceptions": [ 850 "exceptions": [
977 { 851 {
978 "os": { 852 "os": {
979 "type": "android" 853 "type": "android"
980 }, 854 },
981 "machine_model_name": ["Nexus.*"] 855 "machine_model_name": ["Nexus 4"]
982 } 856 }
983 ], 857 ],
984 "features": [ 858 "features": [
985 "test_feature_0" 859 "test_feature_0"
986 ] 860 ]
987 } 861 }
988 ); 862 );
989 ScopedEntry entry(GetEntryFromString(json)); 863 ScopedEntry entry(GetEntryFromString(json));
990 EXPECT_TRUE(entry.get() != NULL); 864 EXPECT_TRUE(entry.get() != NULL);
991 EXPECT_EQ(GpuControlList::kOsAny, entry->GetOsType()); 865 EXPECT_EQ(GpuControlList::kOsAny, entry->GetOsType());
992 GPUInfo gpu_info; 866 GPUInfo gpu_info;
993 867
994 gpu_info.machine_model_name = "Nexus 4"; 868 gpu_info.machine_model_name = "Nexus 4";
995 EXPECT_FALSE(entry->Contains( 869 EXPECT_FALSE(entry->Contains(
996 GpuControlList::kOsAndroid, "4.1", gpu_info)); 870 GpuControlList::kOsAndroid, "4.1", gpu_info));
997 EXPECT_TRUE(entry->Contains( 871 EXPECT_TRUE(entry->Contains(
998 GpuControlList::kOsLinux, "4.1", gpu_info)); 872 GpuControlList::kOsLinux, "4.1", gpu_info));
999 873
1000 gpu_info.machine_model_name = "Nexus 7";
1001 EXPECT_FALSE(entry->Contains(
1002 GpuControlList::kOsAndroid, "4.1", gpu_info));
1003 EXPECT_TRUE(entry->Contains(
1004 GpuControlList::kOsLinux, "4.1", gpu_info));
1005
1006 gpu_info.machine_model_name = ""; 874 gpu_info.machine_model_name = "";
1007 EXPECT_TRUE(entry->Contains( 875 EXPECT_TRUE(entry->Contains(
1008 GpuControlList::kOsAndroid, "4.1", gpu_info)); 876 GpuControlList::kOsAndroid, "4.1", gpu_info));
1009 EXPECT_TRUE(entry->Contains( 877 EXPECT_TRUE(entry->Contains(
1010 GpuControlList::kOsLinux, "4.1", gpu_info)); 878 GpuControlList::kOsLinux, "4.1", gpu_info));
1011 } 879 }
1012 880
1013 TEST_F(GpuControlListEntryTest, MachineModelVersion) { 881 TEST_F(GpuControlListEntryTest, MachineModelVersion) {
1014 const std::string json = LONG_STRING_CONST( 882 const std::string json = LONG_STRING_CONST(
1015 { 883 {
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 ); 1150 );
1283 // By default, secondary GPU is active. 1151 // By default, secondary GPU is active.
1284 EntryShouldNotApply(json); 1152 EntryShouldNotApply(json);
1285 1153
1286 ActivatePrimaryGPU(); 1154 ActivatePrimaryGPU();
1287 EntryShouldApply(json); 1155 EntryShouldApply(json);
1288 } 1156 }
1289 1157
1290 } // namespace gpu 1158 } // namespace gpu
1291 1159
OLDNEW
« no previous file with comments | « trunk/src/gpu/config/gpu_control_list.cc ('k') | trunk/src/gpu/config/gpu_control_list_format.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698