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

Side by Side Diff: extensions/browser/api_test_utils.cc

Issue 1968083004: Implement the private API for quick unlock. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Migrate browser tests to unit tests Created 4 years, 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/api_test_utils.h" 5 #include "extensions/browser/api_test_utils.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 EXPECT_TRUE(function->GetError().empty()) 152 EXPECT_TRUE(function->GetError().empty())
153 << "Unexpected error: " << function->GetError(); 153 << "Unexpected error: " << function->GetError();
154 const base::Value* single_result = NULL; 154 const base::Value* single_result = NULL;
155 if (function->GetResultList() != NULL && 155 if (function->GetResultList() != NULL &&
156 function->GetResultList()->Get(0, &single_result)) { 156 function->GetResultList()->Get(0, &single_result)) {
157 return single_result->DeepCopy(); 157 return single_result->DeepCopy();
158 } 158 }
159 return NULL; 159 return NULL;
160 } 160 }
161 161
162 base::Value* RunFunctionWithDelegateAndReturnSingleResult(
Devlin 2016/06/06 16:35:01 If you want to add this, we should do a few things
jdufault 2016/06/08 18:39:10 I've made the other version call into this one. B
Devlin 2016/06/08 23:26:41 The old versions of this *should* return a std::un
Devlin 2016/06/13 14:50:23 Looks like this still needs to be done?
jdufault 2016/06/20 22:18:25 I've changed the APIs. This propagated to a number
163 UIThreadExtensionFunction* function,
164 std::unique_ptr<base::ListValue> args,
165 content::BrowserContext* context,
166 std::unique_ptr<extensions::ExtensionFunctionDispatcher> dispatcher,
167 RunFunctionFlags flags) {
168 scoped_refptr<ExtensionFunction> function_owner(function);
169 // Without a callback the function will not generate a result.
170 function->set_has_callback(true);
171 RunFunction(function, std::move(args), context, std::move(dispatcher), flags);
172 EXPECT_TRUE(function->GetError().empty()) << "Unexpected error: "
173 << function->GetError();
174 const base::Value* single_result = NULL;
175 if (function->GetResultList() != NULL &&
176 function->GetResultList()->Get(0, &single_result)) {
177 return single_result->DeepCopy();
178 }
179 return NULL;
180 }
181
162 base::Value* RunFunctionAndReturnSingleResult( 182 base::Value* RunFunctionAndReturnSingleResult(
163 UIThreadExtensionFunction* function, 183 UIThreadExtensionFunction* function,
164 const std::string& args, 184 const std::string& args,
165 content::BrowserContext* context) { 185 content::BrowserContext* context) {
166 return RunFunctionAndReturnSingleResult(function, args, context, NONE); 186 return RunFunctionAndReturnSingleResult(function, args, context, NONE);
167 } 187 }
168 188
169 base::Value* RunFunctionAndReturnSingleResult( 189 base::Value* RunFunctionAndReturnSingleResult(
170 UIThreadExtensionFunction* function, 190 UIThreadExtensionFunction* function,
171 const std::string& args, 191 const std::string& args,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 function->set_include_incognito(flags & INCLUDE_INCOGNITO); 256 function->set_include_incognito(flags & INCLUDE_INCOGNITO);
237 function->Run()->Execute(); 257 function->Run()->Execute();
238 response_delegate.WaitForResponse(); 258 response_delegate.WaitForResponse();
239 259
240 EXPECT_TRUE(response_delegate.HasResponse()); 260 EXPECT_TRUE(response_delegate.HasResponse());
241 return response_delegate.GetResponse(); 261 return response_delegate.GetResponse();
242 } 262 }
243 263
244 } // namespace api_test_utils 264 } // namespace api_test_utils
245 } // namespace extensions 265 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698