- add sources.
[platform/framework/web/crosswalk.git] / src / gpu / config / gpu_blacklist_unittest.cc
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
3 // found in the LICENSE file.
4
5 #include "base/memory/scoped_ptr.h"
6 #include "gpu/config/gpu_blacklist.h"
7 #include "gpu/config/gpu_control_list_jsons.h"
8 #include "gpu/config/gpu_feature_type.h"
9 #include "gpu/config/gpu_info.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 const char kOsVersion[] = "10.6.4";
13
14 namespace gpu {
15
16 class GpuBlacklistTest : public testing::Test {
17  public:
18   GpuBlacklistTest() { }
19
20   virtual ~GpuBlacklistTest() { }
21
22   const GPUInfo& gpu_info() const {
23     return gpu_info_;
24   }
25
26   void RunFeatureTest(
27       const std::string feature_name, GpuFeatureType feature_type) {
28     const std::string json =
29         "{\n"
30         "  \"name\": \"gpu blacklist\",\n"
31         "  \"version\": \"0.1\",\n"
32         "  \"entries\": [\n"
33         "    {\n"
34         "      \"id\": 1,\n"
35         "      \"os\": {\n"
36         "        \"type\": \"macosx\"\n"
37         "      },\n"
38         "      \"vendor_id\": \"0x10de\",\n"
39         "      \"device_id\": [\"0x0640\"],\n"
40         "      \"features\": [\n"
41         "        \"" +
42         feature_name +
43         "\"\n"
44         "      ]\n"
45         "    }\n"
46         "  ]\n"
47         "}";
48
49     scoped_ptr<GpuBlacklist> blacklist(GpuBlacklist::Create());
50     EXPECT_TRUE(blacklist->LoadList(json, GpuBlacklist::kAllOs));
51     std::set<int> type = blacklist->MakeDecision(
52         GpuBlacklist::kOsMacosx, kOsVersion, gpu_info());
53     EXPECT_EQ(1u, type.size());
54     EXPECT_EQ(1u, type.count(feature_type));
55   }
56
57  protected:
58   virtual void SetUp() {
59     gpu_info_.gpu.vendor_id = 0x10de;
60     gpu_info_.gpu.device_id = 0x0640;
61     gpu_info_.driver_vendor = "NVIDIA";
62     gpu_info_.driver_version = "1.6.18";
63     gpu_info_.driver_date = "7-14-2009";
64     gpu_info_.machine_model = "MacBookPro 7.1";
65     gpu_info_.gl_vendor = "NVIDIA Corporation";
66     gpu_info_.gl_renderer = "NVIDIA GeForce GT 120 OpenGL Engine";
67     gpu_info_.performance_stats.graphics = 5.0;
68     gpu_info_.performance_stats.gaming = 5.0;
69     gpu_info_.performance_stats.overall = 5.0;
70   }
71
72   virtual void TearDown() {
73   }
74
75  private:
76   GPUInfo gpu_info_;
77 };
78
79 TEST_F(GpuBlacklistTest, CurrentBlacklistValidation) {
80   scoped_ptr<GpuBlacklist> blacklist(GpuBlacklist::Create());
81   EXPECT_TRUE(blacklist->LoadList(
82       kSoftwareRenderingListJson, GpuBlacklist::kAllOs));
83 }
84
85 #define GPU_BLACKLIST_FEATURE_TEST(test_name, feature_name, feature_type) \
86 TEST_F(GpuBlacklistTest, test_name) {                                     \
87   RunFeatureTest(feature_name, feature_type);                             \
88 }
89
90 GPU_BLACKLIST_FEATURE_TEST(Accelerated2DCanvas,
91                            "accelerated_2d_canvas",
92                            GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)
93
94 GPU_BLACKLIST_FEATURE_TEST(AcceleratedCompositing,
95                            "accelerated_compositing",
96                            GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING)
97
98 GPU_BLACKLIST_FEATURE_TEST(WebGL,
99                            "webgl",
100                            GPU_FEATURE_TYPE_WEBGL)
101
102 GPU_BLACKLIST_FEATURE_TEST(Multisampling,
103                            "multisampling",
104                            GPU_FEATURE_TYPE_MULTISAMPLING)
105
106 GPU_BLACKLIST_FEATURE_TEST(Flash3D,
107                            "flash_3d",
108                            GPU_FEATURE_TYPE_FLASH3D)
109
110 GPU_BLACKLIST_FEATURE_TEST(FlashStage3D,
111                            "flash_stage3d",
112                            GPU_FEATURE_TYPE_FLASH_STAGE3D)
113
114 GPU_BLACKLIST_FEATURE_TEST(FlashStage3DBaseline,
115                            "flash_stage3d_baseline",
116                            GPU_FEATURE_TYPE_FLASH_STAGE3D_BASELINE)
117
118 GPU_BLACKLIST_FEATURE_TEST(TextureSharing,
119                            "texture_sharing",
120                            GPU_FEATURE_TYPE_TEXTURE_SHARING)
121
122 GPU_BLACKLIST_FEATURE_TEST(AcceleratedVideoDecode,
123                            "accelerated_video_decode",
124                            GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE)
125
126 GPU_BLACKLIST_FEATURE_TEST(Css3D,
127                            "3d_css",
128                            GPU_FEATURE_TYPE_3D_CSS)
129
130 GPU_BLACKLIST_FEATURE_TEST(AcceleratedVideo,
131                            "accelerated_video",
132                            GPU_FEATURE_TYPE_ACCELERATED_VIDEO)
133
134 GPU_BLACKLIST_FEATURE_TEST(PanelFitting,
135                            "panel_fitting",
136                            GPU_FEATURE_TYPE_PANEL_FITTING)
137
138 GPU_BLACKLIST_FEATURE_TEST(ForceCompositingMode,
139                            "force_compositing_mode",
140                            GPU_FEATURE_TYPE_FORCE_COMPOSITING_MODE)
141
142 }  // namespace gpu