1 // Copyright (c) 2011 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 "gpu/config/gpu_util.h"
6 
7 #include "base/command_line.h"
8 #include "gpu/config/gpu_driver_bug_workaround_type.h"
9 #include "gpu/config/gpu_info.h"
10 #include "gpu/config/gpu_preferences.h"
11 #include "gpu/config/gpu_switches.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13 
14 namespace gpu {
15 
TEST(GpuUtilTest,GetGpuFeatureInfo_WorkaroundFromCommandLine)16 TEST(GpuUtilTest, GetGpuFeatureInfo_WorkaroundFromCommandLine) {
17   {
18     base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
19     GPUInfo gpu_info;
20     GpuFeatureInfo gpu_feature_info = ComputeGpuFeatureInfo(
21         gpu_info, GpuPreferences(), &command_line, nullptr);
22     EXPECT_FALSE(gpu_feature_info.IsWorkaroundEnabled(
23         USE_GPU_DRIVER_WORKAROUND_FOR_TESTING));
24   }
25 
26   {
27     base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
28     command_line.AppendSwitchASCII(GpuDriverBugWorkaroundTypeToString(
29                                        USE_GPU_DRIVER_WORKAROUND_FOR_TESTING),
30                                    "1");
31     GPUInfo gpu_info;
32     GpuFeatureInfo gpu_feature_info = ComputeGpuFeatureInfo(
33         gpu_info, GpuPreferences(), &command_line, nullptr);
34     EXPECT_TRUE(gpu_feature_info.IsWorkaroundEnabled(
35         USE_GPU_DRIVER_WORKAROUND_FOR_TESTING));
36   }
37 
38   {
39     base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
40     command_line.AppendSwitchASCII(switches::kGpuDriverBugListTestGroup, "1");
41     // See gpu/config/gpu_driver_bug_list.json, test_group 1, entry 215.
42     GPUInfo gpu_info;
43     GpuFeatureInfo gpu_feature_info = ComputeGpuFeatureInfo(
44         gpu_info, GpuPreferences(), &command_line, nullptr);
45     EXPECT_TRUE(gpu_feature_info.IsWorkaroundEnabled(
46         USE_GPU_DRIVER_WORKAROUND_FOR_TESTING));
47   }
48 
49   {
50     base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
51     command_line.AppendSwitchASCII(switches::kGpuDriverBugListTestGroup, "1");
52     command_line.AppendSwitchASCII(GpuDriverBugWorkaroundTypeToString(
53                                        USE_GPU_DRIVER_WORKAROUND_FOR_TESTING),
54                                    "0");
55     // See gpu/config/gpu_driver_bug_list.json, test_group 1, entry 215.
56     GPUInfo gpu_info;
57     GpuFeatureInfo gpu_feature_info = ComputeGpuFeatureInfo(
58         gpu_info, GpuPreferences(), &command_line, nullptr);
59     EXPECT_FALSE(gpu_feature_info.IsWorkaroundEnabled(
60         USE_GPU_DRIVER_WORKAROUND_FOR_TESTING));
61   }
62 }
63 
64 }  // namespace gpu
65