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

Side by Side Diff: content/browser/gpu/gpu_switching_list_unittest.cc

Issue 15094006: Change gpu blacklists from json resource to const string. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 7 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 <vector> 5 #include <vector>
6 6
7 #include "base/base_paths.h"
8 #include "base/file_util.h"
9 #include "base/files/file_path.h"
10 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
11 #include "base/path_service.h" 8 #include "content/browser/gpu/gpu_control_list_jsons.h"
12 #include "content/browser/gpu/gpu_switching_list.h" 9 #include "content/browser/gpu/gpu_switching_list.h"
13 #include "content/public/common/gpu_info.h" 10 #include "content/public/common/gpu_info.h"
14 #include "content/public/common/gpu_switching_option.h" 11 #include "content/public/common/gpu_switching_option.h"
15 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
16 13
17 #define LONG_STRING_CONST(...) #__VA_ARGS__ 14 #define LONG_STRING_CONST(...) #__VA_ARGS__
18 15
19 const char kOsVersion[] = "10.6.4"; 16 const char kOsVersion[] = "10.6.4";
20 17
21 namespace content { 18 namespace content {
(...skipping 24 matching lines...) Expand all
46 } 43 }
47 44
48 virtual void TearDown() { 45 virtual void TearDown() {
49 } 46 }
50 47
51 private: 48 private:
52 GPUInfo gpu_info_; 49 GPUInfo gpu_info_;
53 }; 50 };
54 51
55 TEST_F(GpuSwitchingListTest, CurrentSwitchingListValidation) { 52 TEST_F(GpuSwitchingListTest, CurrentSwitchingListValidation) {
56 base::FilePath data_file;
57 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &data_file));
58 data_file =
59 data_file.Append(FILE_PATH_LITERAL("content"))
60 .Append(FILE_PATH_LITERAL("browser"))
61 .Append(FILE_PATH_LITERAL("gpu"))
62 .Append(FILE_PATH_LITERAL("gpu_switching_list.json"));
63 ASSERT_TRUE(file_util::PathExists(data_file));
64 int64 data_file_size64 = 0;
65 ASSERT_TRUE(file_util::GetFileSize(data_file, &data_file_size64));
66 int data_file_size = static_cast<int>(data_file_size64);
67 scoped_ptr<char[]> data(new char[data_file_size]);
68 ASSERT_EQ(data_file_size,
69 file_util::ReadFile(data_file, data.get(), data_file_size));
70 std::string json_string(data.get(), data_file_size);
71 scoped_ptr<GpuSwitchingList> switching_list(GpuSwitchingList::Create()); 53 scoped_ptr<GpuSwitchingList> switching_list(GpuSwitchingList::Create());
72 EXPECT_TRUE(switching_list->LoadList(json_string, GpuControlList::kAllOs)); 54 EXPECT_TRUE(switching_list->LoadList(
55 kGpuSwitchingListJson, GpuControlList::kAllOs));
73 EXPECT_FALSE(switching_list->contains_unknown_fields()); 56 EXPECT_FALSE(switching_list->contains_unknown_fields());
74 } 57 }
75 58
76 TEST_F(GpuSwitchingListTest, GpuSwitching) { 59 TEST_F(GpuSwitchingListTest, GpuSwitching) {
77 const std::string json = LONG_STRING_CONST( 60 const std::string json = LONG_STRING_CONST(
78 { 61 {
79 "name": "gpu switching list", 62 "name": "gpu switching list",
80 "version": "0.1", 63 "version": "0.1",
81 "entries": [ 64 "entries": [
82 { 65 {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 GpuControlList::kOsWin, kOsVersion, gpu_info()); 100 GpuControlList::kOsWin, kOsVersion, gpu_info());
118 EXPECT_EQ(1u, switching.size()); 101 EXPECT_EQ(1u, switching.size());
119 EXPECT_EQ(1u, switching.count(GPU_SWITCHING_OPTION_FORCE_INTEGRATED)); 102 EXPECT_EQ(1u, switching.count(GPU_SWITCHING_OPTION_FORCE_INTEGRATED));
120 switching_list->GetDecisionEntries(&entries, false); 103 switching_list->GetDecisionEntries(&entries, false);
121 ASSERT_EQ(1u, entries.size()); 104 ASSERT_EQ(1u, entries.size());
122 EXPECT_EQ(2u, entries[0]); 105 EXPECT_EQ(2u, entries[0]);
123 } 106 }
124 107
125 } // namespace content 108 } // namespace content
126 109
OLDNEW
« no previous file with comments | « content/browser/gpu/gpu_switching_list_json.cc ('k') | content/browser/gpu/software_rendering_list.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698