1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "gpu/config/gpu_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gl/gl_switches.h"
namespace gpu {
TEST(GpuUtilTest, GpuSwitchingOptionFromString) {
// Test StringToGpuSwitchingOption.
EXPECT_EQ(StringToGpuSwitchingOption(
switches::kGpuSwitchingOptionNameAutomatic),
GPU_SWITCHING_OPTION_AUTOMATIC);
EXPECT_EQ(StringToGpuSwitchingOption(
switches::kGpuSwitchingOptionNameForceDiscrete),
GPU_SWITCHING_OPTION_FORCE_DISCRETE);
EXPECT_EQ(StringToGpuSwitchingOption(
switches::kGpuSwitchingOptionNameForceIntegrated),
GPU_SWITCHING_OPTION_FORCE_INTEGRATED);
EXPECT_EQ(StringToGpuSwitchingOption("xxx"), GPU_SWITCHING_OPTION_UNKNOWN);
}
TEST(GpuUtilTest, GpuSwitchingOptionToString) {
// Test GpuSwitchingOptionToString.
EXPECT_STREQ(
GpuSwitchingOptionToString(GPU_SWITCHING_OPTION_AUTOMATIC).c_str(),
switches::kGpuSwitchingOptionNameAutomatic);
EXPECT_STREQ(
GpuSwitchingOptionToString(GPU_SWITCHING_OPTION_FORCE_DISCRETE).c_str(),
switches::kGpuSwitchingOptionNameForceDiscrete);
EXPECT_STREQ(
GpuSwitchingOptionToString(GPU_SWITCHING_OPTION_FORCE_INTEGRATED).c_str(),
switches::kGpuSwitchingOptionNameForceIntegrated);
}
TEST(GpuUtilTest, MergeFeatureSets) {
{
// Merge two empty sets.
std::set<int> src;
std::set<int> dst;
EXPECT_TRUE(dst.empty());
MergeFeatureSets(&dst, src);
EXPECT_TRUE(dst.empty());
}
{
// Merge an empty set into a set with elements.
std::set<int> src;
std::set<int> dst;
dst.insert(1);
EXPECT_EQ(1u, dst.size());
MergeFeatureSets(&dst, src);
EXPECT_EQ(1u, dst.size());
}
{
// Merge two sets where the source elements are already in the target set.
std::set<int> src;
std::set<int> dst;
src.insert(1);
dst.insert(1);
EXPECT_EQ(1u, dst.size());
MergeFeatureSets(&dst, src);
EXPECT_EQ(1u, dst.size());
}
{
// Merge two sets with different elements.
std::set<int> src;
std::set<int> dst;
src.insert(1);
dst.insert(2);
EXPECT_EQ(1u, dst.size());
MergeFeatureSets(&dst, src);
EXPECT_EQ(2u, dst.size());
}
}
} // namespace gpu
|