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

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

Issue 409743003: Use content::RunBlockingPoolTask() in tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed. Created 6 years, 3 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) 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 "chrome/browser/extensions/requirements_checker.h"
6
5 #include <vector> 7 #include <vector>
6 8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
9 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
10 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
11 #include "base/path_service.h" 13 #include "base/path_service.h"
12 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
13 #include "chrome/browser/extensions/extension_browsertest.h" 15 #include "chrome/browser/extensions/extension_browsertest.h"
14 #include "chrome/browser/extensions/requirements_checker.h"
15 #include "chrome/common/chrome_paths.h" 16 #include "chrome/common/chrome_paths.h"
16 #include "chrome/grit/generated_resources.h" 17 #include "chrome/grit/generated_resources.h"
17 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/gpu_data_manager.h" 19 #include "content/public/browser/gpu_data_manager.h"
20 #include "content/public/test/test_utils.h"
19 #include "extensions/common/extension.h" 21 #include "extensions/common/extension.h"
20 #include "extensions/common/file_util.h" 22 #include "extensions/common/file_util.h"
21 #include "gpu/config/gpu_info.h" 23 #include "gpu/config/gpu_info.h"
22 #include "ui/base/l10n/l10n_util.h" 24 #include "ui/base/l10n/l10n_util.h"
23 25
24 namespace extensions { 26 namespace extensions {
25 27
26 class RequirementsCheckerBrowserTest : public ExtensionBrowserTest { 28 class RequirementsCheckerBrowserTest : public ExtensionBrowserTest {
27 public: 29 public:
28 scoped_refptr<const Extension> LoadExtensionFromDirName( 30 scoped_refptr<const Extension> LoadExtensionFromDirName(
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 RequirementsChecker checker_; 77 RequirementsChecker checker_;
76 }; 78 };
77 79
78 IN_PROC_BROWSER_TEST_F(RequirementsCheckerBrowserTest, CheckEmptyExtension) { 80 IN_PROC_BROWSER_TEST_F(RequirementsCheckerBrowserTest, CheckEmptyExtension) {
79 scoped_refptr<const Extension> extension( 81 scoped_refptr<const Extension> extension(
80 LoadExtensionFromDirName("no_requirements")); 82 LoadExtensionFromDirName("no_requirements"));
81 ASSERT_TRUE(extension.get()); 83 ASSERT_TRUE(extension.get());
82 checker_.Check(extension, base::Bind( 84 checker_.Check(extension, base::Bind(
83 &RequirementsCheckerBrowserTest::ValidateRequirementErrors, 85 &RequirementsCheckerBrowserTest::ValidateRequirementErrors,
84 base::Unretained(this), std::vector<std::string>())); 86 base::Unretained(this), std::vector<std::string>()));
85 content::BrowserThread::GetBlockingPool()->FlushForTesting(); 87 content::RunAllBlockingPoolTasksUntilIdle();
86 } 88 }
87 89
88 IN_PROC_BROWSER_TEST_F(RequirementsCheckerBrowserTest, CheckNpapiExtension) { 90 IN_PROC_BROWSER_TEST_F(RequirementsCheckerBrowserTest, CheckNpapiExtension) {
89 scoped_refptr<const Extension> extension( 91 scoped_refptr<const Extension> extension(
90 LoadExtensionFromDirName("require_npapi")); 92 LoadExtensionFromDirName("require_npapi"));
91 ASSERT_TRUE(extension.get()); 93 ASSERT_TRUE(extension.get());
92 94
93 std::vector<std::string> expected_errors; 95 std::vector<std::string> expected_errors;
94 #if defined(OS_POSIX) && !defined(OS_MACOSX) 96 #if defined(OS_POSIX) && !defined(OS_MACOSX)
95 expected_errors.push_back(l10n_util::GetStringUTF8( 97 expected_errors.push_back(l10n_util::GetStringUTF8(
96 IDS_EXTENSION_NPAPI_NOT_SUPPORTED)); 98 IDS_EXTENSION_NPAPI_NOT_SUPPORTED));
97 #endif 99 #endif
98 100
99 checker_.Check(extension, base::Bind( 101 checker_.Check(extension, base::Bind(
100 &RequirementsCheckerBrowserTest::ValidateRequirementErrors, 102 &RequirementsCheckerBrowserTest::ValidateRequirementErrors,
101 base::Unretained(this), expected_errors)); 103 base::Unretained(this), expected_errors));
102 content::BrowserThread::GetBlockingPool()->FlushForTesting(); 104 content::RunAllBlockingPoolTasksUntilIdle();
103 } 105 }
104 106
105 IN_PROC_BROWSER_TEST_F(RequirementsCheckerBrowserTest, 107 IN_PROC_BROWSER_TEST_F(RequirementsCheckerBrowserTest,
106 CheckWindowShapeExtension) { 108 CheckWindowShapeExtension) {
107 scoped_refptr<const Extension> extension( 109 scoped_refptr<const Extension> extension(
108 LoadExtensionFromDirName("require_window_shape")); 110 LoadExtensionFromDirName("require_window_shape"));
109 ASSERT_TRUE(extension.get()); 111 ASSERT_TRUE(extension.get());
110 112
111 std::vector<std::string> expected_errors; 113 std::vector<std::string> expected_errors;
112 #if !defined(USE_AURA) 114 #if !defined(USE_AURA)
113 expected_errors.push_back(l10n_util::GetStringUTF8( 115 expected_errors.push_back(l10n_util::GetStringUTF8(
114 IDS_EXTENSION_WINDOW_SHAPE_NOT_SUPPORTED)); 116 IDS_EXTENSION_WINDOW_SHAPE_NOT_SUPPORTED));
115 #endif // !defined(USE_AURA) 117 #endif // !defined(USE_AURA)
116 118
117 checker_.Check(extension, base::Bind( 119 checker_.Check(extension, base::Bind(
118 &RequirementsCheckerBrowserTest::ValidateRequirementErrors, 120 &RequirementsCheckerBrowserTest::ValidateRequirementErrors,
119 base::Unretained(this), expected_errors)); 121 base::Unretained(this), expected_errors));
120 content::BrowserThread::GetBlockingPool()->FlushForTesting(); 122 content::RunAllBlockingPoolTasksUntilIdle();
121 } 123 }
122 124
123 IN_PROC_BROWSER_TEST_F(RequirementsCheckerBrowserTest, DisallowWebGL) { 125 IN_PROC_BROWSER_TEST_F(RequirementsCheckerBrowserTest, DisallowWebGL) {
124 scoped_refptr<const Extension> extension( 126 scoped_refptr<const Extension> extension(
125 LoadExtensionFromDirName("require_3d")); 127 LoadExtensionFromDirName("require_3d"));
126 ASSERT_TRUE(extension.get()); 128 ASSERT_TRUE(extension.get());
127 129
128 // Backlist webgl 130 // Backlist webgl
129 std::vector<std::string> blacklisted_features; 131 std::vector<std::string> blacklisted_features;
130 blacklisted_features.push_back("webgl"); 132 blacklisted_features.push_back("webgl");
131 BlackListGPUFeatures(blacklisted_features); 133 BlackListGPUFeatures(blacklisted_features);
132 content::BrowserThread::GetBlockingPool()->FlushForTesting(); 134 content::RunAllBlockingPoolTasksUntilIdle();
133 135
134 std::vector<std::string> expected_errors; 136 std::vector<std::string> expected_errors;
135 expected_errors.push_back(l10n_util::GetStringUTF8( 137 expected_errors.push_back(l10n_util::GetStringUTF8(
136 IDS_EXTENSION_WEBGL_NOT_SUPPORTED)); 138 IDS_EXTENSION_WEBGL_NOT_SUPPORTED));
137 139
138 checker_.Check(extension, base::Bind( 140 checker_.Check(extension, base::Bind(
139 &RequirementsCheckerBrowserTest::ValidateRequirementErrors, 141 &RequirementsCheckerBrowserTest::ValidateRequirementErrors,
140 base::Unretained(this), expected_errors)); 142 base::Unretained(this), expected_errors));
141 content::BrowserThread::GetBlockingPool()->FlushForTesting(); 143 content::RunAllBlockingPoolTasksUntilIdle();
142 } 144 }
143 145
144 IN_PROC_BROWSER_TEST_F(RequirementsCheckerBrowserTest, Check3DExtension) { 146 IN_PROC_BROWSER_TEST_F(RequirementsCheckerBrowserTest, Check3DExtension) {
145 scoped_refptr<const Extension> extension( 147 scoped_refptr<const Extension> extension(
146 LoadExtensionFromDirName("require_3d")); 148 LoadExtensionFromDirName("require_3d"));
147 ASSERT_TRUE(extension.get()); 149 ASSERT_TRUE(extension.get());
148 150
149 std::vector<std::string> expected_errors; 151 std::vector<std::string> expected_errors;
150 152
151 if (!content::GpuDataManager::GetInstance()->GpuAccessAllowed(NULL)) { 153 if (!content::GpuDataManager::GetInstance()->GpuAccessAllowed(NULL)) {
152 expected_errors.push_back(l10n_util::GetStringUTF8( 154 expected_errors.push_back(l10n_util::GetStringUTF8(
153 IDS_EXTENSION_WEBGL_NOT_SUPPORTED)); 155 IDS_EXTENSION_WEBGL_NOT_SUPPORTED));
154 } 156 }
155 157
156 checker_.Check(extension, base::Bind( 158 checker_.Check(extension, base::Bind(
157 &RequirementsCheckerBrowserTest::ValidateRequirementErrors, 159 &RequirementsCheckerBrowserTest::ValidateRequirementErrors,
158 base::Unretained(this), expected_errors)); 160 base::Unretained(this), expected_errors));
159 content::BrowserThread::GetBlockingPool()->FlushForTesting(); 161 content::RunAllBlockingPoolTasksUntilIdle();
160 } 162 }
161 163
162 } // namespace extensions 164 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698