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

Side by Side Diff: chrome/browser/extensions/requirements_checker_browsertest.cc

Issue 2776263004: expect the test finishes
Patch Set: Created 3 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 29 matching lines...) Expand all
40 scoped_refptr<const Extension> extension = file_util::LoadExtension( 40 scoped_refptr<const Extension> extension = file_util::LoadExtension(
41 extension_path, Manifest::UNPACKED, 0, &load_error); 41 extension_path, Manifest::UNPACKED, 0, &load_error);
42 CHECK_EQ(0U, load_error.length()); 42 CHECK_EQ(0U, load_error.length());
43 return extension; 43 return extension;
44 } 44 }
45 45
46 void ValidateRequirementErrors( 46 void ValidateRequirementErrors(
47 const std::vector<std::string>& expected_errors, 47 const std::vector<std::string>& expected_errors,
48 const std::vector<std::string>& actual_errors) { 48 const std::vector<std::string>& actual_errors) {
49 ASSERT_EQ(expected_errors, actual_errors); 49 ASSERT_EQ(expected_errors, actual_errors);
50 finished_ = true;
50 } 51 }
51 52
52 // This should only be called once per test instance. Calling more than once 53 // This should only be called once per test instance. Calling more than once
53 // will result in stale information in the GPUDataManager which will throw off 54 // will result in stale information in the GPUDataManager which will throw off
54 // the RequirementsChecker. 55 // the RequirementsChecker.
55 void BlackListGPUFeatures(const std::vector<std::string>& features) { 56 void BlackListGPUFeatures(const std::vector<std::string>& features) {
56 #if !defined(NDEBUG) 57 #if !defined(NDEBUG)
57 static bool called = false; 58 static bool called = false;
58 DCHECK(!called); 59 DCHECK(!called);
59 called = true; 60 called = true;
(...skipping 10 matching lines...) Expand all
70 " }\n" 71 " }\n"
71 " ]\n" 72 " ]\n"
72 "}"; 73 "}";
73 gpu::GPUInfo gpu_info; 74 gpu::GPUInfo gpu_info;
74 content::GpuDataManager::GetInstance()->InitializeForTesting( 75 content::GpuDataManager::GetInstance()->InitializeForTesting(
75 json_blacklist, gpu_info); 76 json_blacklist, gpu_info);
76 } 77 }
77 78
78 protected: 79 protected:
79 std::unique_ptr<RequirementsChecker> checker_; 80 std::unique_ptr<RequirementsChecker> checker_;
81 bool finished_ = false;
80 }; 82 };
81 83
82 IN_PROC_BROWSER_TEST_F(RequirementsCheckerBrowserTest, CheckEmptyExtension) { 84 IN_PROC_BROWSER_TEST_F(RequirementsCheckerBrowserTest, CheckEmptyExtension) {
83 scoped_refptr<const Extension> extension( 85 scoped_refptr<const Extension> extension(
84 LoadExtensionFromDirName("no_requirements")); 86 LoadExtensionFromDirName("no_requirements"));
85 ASSERT_TRUE(extension.get()); 87 ASSERT_TRUE(extension.get());
86 checker_->Check(extension, base::Bind( 88 checker_->Check(extension, base::Bind(
87 &RequirementsCheckerBrowserTest::ValidateRequirementErrors, 89 &RequirementsCheckerBrowserTest::ValidateRequirementErrors,
88 base::Unretained(this), std::vector<std::string>())); 90 base::Unretained(this), std::vector<std::string>()));
89 content::RunAllBlockingPoolTasksUntilIdle(); 91 content::RunAllBlockingPoolTasksUntilIdle();
92 EXPECT_TRUE(finished_);
90 } 93 }
91 94
92 IN_PROC_BROWSER_TEST_F(RequirementsCheckerBrowserTest, CheckNpapiExtension) { 95 IN_PROC_BROWSER_TEST_F(RequirementsCheckerBrowserTest, CheckNpapiExtension) {
93 scoped_refptr<const Extension> extension( 96 scoped_refptr<const Extension> extension(
94 LoadExtensionFromDirName("require_npapi")); 97 LoadExtensionFromDirName("require_npapi"));
95 ASSERT_TRUE(extension.get()); 98 ASSERT_TRUE(extension.get());
96 99
97 std::vector<std::string> expected_errors; 100 std::vector<std::string> expected_errors;
98 #if defined(OS_POSIX) && !defined(OS_MACOSX) 101 #if defined(OS_POSIX) && !defined(OS_MACOSX)
99 expected_errors.push_back(l10n_util::GetStringUTF8( 102 expected_errors.push_back(l10n_util::GetStringUTF8(
100 IDS_EXTENSION_NPAPI_NOT_SUPPORTED)); 103 IDS_EXTENSION_NPAPI_NOT_SUPPORTED));
101 #endif 104 #endif
102 105
103 checker_->Check(extension, base::Bind( 106 checker_->Check(extension, base::Bind(
104 &RequirementsCheckerBrowserTest::ValidateRequirementErrors, 107 &RequirementsCheckerBrowserTest::ValidateRequirementErrors,
105 base::Unretained(this), expected_errors)); 108 base::Unretained(this), expected_errors));
106 content::RunAllBlockingPoolTasksUntilIdle(); 109 content::RunAllBlockingPoolTasksUntilIdle();
110 EXPECT_TRUE(finished_);
107 } 111 }
108 112
109 IN_PROC_BROWSER_TEST_F(RequirementsCheckerBrowserTest, 113 IN_PROC_BROWSER_TEST_F(RequirementsCheckerBrowserTest,
110 CheckWindowShapeExtension) { 114 CheckWindowShapeExtension) {
111 scoped_refptr<const Extension> extension( 115 scoped_refptr<const Extension> extension(
112 LoadExtensionFromDirName("require_window_shape")); 116 LoadExtensionFromDirName("require_window_shape"));
113 ASSERT_TRUE(extension.get()); 117 ASSERT_TRUE(extension.get());
114 118
115 std::vector<std::string> expected_errors; 119 std::vector<std::string> expected_errors;
116 #if !defined(USE_AURA) 120 #if !defined(USE_AURA)
117 expected_errors.push_back(l10n_util::GetStringUTF8( 121 expected_errors.push_back(l10n_util::GetStringUTF8(
118 IDS_EXTENSION_WINDOW_SHAPE_NOT_SUPPORTED)); 122 IDS_EXTENSION_WINDOW_SHAPE_NOT_SUPPORTED));
119 #endif // !defined(USE_AURA) 123 #endif // !defined(USE_AURA)
120 124
121 checker_->Check(extension, base::Bind( 125 checker_->Check(extension, base::Bind(
122 &RequirementsCheckerBrowserTest::ValidateRequirementErrors, 126 &RequirementsCheckerBrowserTest::ValidateRequirementErrors,
123 base::Unretained(this), expected_errors)); 127 base::Unretained(this), expected_errors));
124 content::RunAllBlockingPoolTasksUntilIdle(); 128 content::RunAllBlockingPoolTasksUntilIdle();
129 EXPECT_TRUE(finished_);
125 } 130 }
126 131
127 IN_PROC_BROWSER_TEST_F(RequirementsCheckerBrowserTest, DisallowWebGL) { 132 IN_PROC_BROWSER_TEST_F(RequirementsCheckerBrowserTest, DisallowWebGL) {
128 scoped_refptr<const Extension> extension( 133 scoped_refptr<const Extension> extension(
129 LoadExtensionFromDirName("require_3d")); 134 LoadExtensionFromDirName("require_3d"));
130 ASSERT_TRUE(extension.get()); 135 ASSERT_TRUE(extension.get());
131 136
132 // Backlist webgl 137 // Backlist webgl
133 std::vector<std::string> blacklisted_features; 138 std::vector<std::string> blacklisted_features;
134 blacklisted_features.push_back("accelerated_webgl"); 139 blacklisted_features.push_back("accelerated_webgl");
135 BlackListGPUFeatures(blacklisted_features); 140 BlackListGPUFeatures(blacklisted_features);
136 content::RunAllBlockingPoolTasksUntilIdle(); 141 content::RunAllBlockingPoolTasksUntilIdle();
137 142
138 std::vector<std::string> expected_errors; 143 std::vector<std::string> expected_errors;
139 expected_errors.push_back(l10n_util::GetStringUTF8( 144 expected_errors.push_back(l10n_util::GetStringUTF8(
140 IDS_EXTENSION_WEBGL_NOT_SUPPORTED)); 145 IDS_EXTENSION_WEBGL_NOT_SUPPORTED));
141 146
142 checker_->Check(extension, base::Bind( 147 checker_->Check(extension, base::Bind(
143 &RequirementsCheckerBrowserTest::ValidateRequirementErrors, 148 &RequirementsCheckerBrowserTest::ValidateRequirementErrors,
144 base::Unretained(this), expected_errors)); 149 base::Unretained(this), expected_errors));
145 content::RunAllBlockingPoolTasksUntilIdle(); 150 content::RunAllBlockingPoolTasksUntilIdle();
151 EXPECT_TRUE(finished_);
146 } 152 }
147 153
148 IN_PROC_BROWSER_TEST_F(RequirementsCheckerBrowserTest, Check3DExtension) { 154 IN_PROC_BROWSER_TEST_F(RequirementsCheckerBrowserTest, Check3DExtension) {
149 scoped_refptr<const Extension> extension( 155 scoped_refptr<const Extension> extension(
150 LoadExtensionFromDirName("require_3d")); 156 LoadExtensionFromDirName("require_3d"));
151 ASSERT_TRUE(extension.get()); 157 ASSERT_TRUE(extension.get());
152 158
153 std::vector<std::string> expected_errors; 159 std::vector<std::string> expected_errors;
154 160
155 if (!content::GpuDataManager::GetInstance()->GpuAccessAllowed(NULL)) { 161 if (!content::GpuDataManager::GetInstance()->GpuAccessAllowed(NULL)) {
156 expected_errors.push_back(l10n_util::GetStringUTF8( 162 expected_errors.push_back(l10n_util::GetStringUTF8(
157 IDS_EXTENSION_WEBGL_NOT_SUPPORTED)); 163 IDS_EXTENSION_WEBGL_NOT_SUPPORTED));
158 } 164 }
159 165
160 checker_->Check(extension, base::Bind( 166 checker_->Check(extension, base::Bind(
161 &RequirementsCheckerBrowserTest::ValidateRequirementErrors, 167 &RequirementsCheckerBrowserTest::ValidateRequirementErrors,
162 base::Unretained(this), expected_errors)); 168 base::Unretained(this), expected_errors));
163 content::RunAllBlockingPoolTasksUntilIdle(); 169 content::RunAllBlockingPoolTasksUntilIdle();
170 EXPECT_TRUE(finished_);
164 } 171 }
165 172
166 } // namespace extensions 173 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698