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

Side by Side Diff: content/browser/indexed_db/idbbindingutilities_browsertest.cc

Issue 10822030: Move ui_test_utils::RunMessageLoop to test_utils so that it can be reused by content_browsertests. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/utf_string_conversions.h" 6 #include "base/utf_string_conversions.h"
7 #include "chrome/test/base/in_process_browser_test.h" 7 #include "chrome/test/base/in_process_browser_test.h"
8 #include "chrome/test/base/ui_test_utils.h" 8 #include "chrome/test/base/ui_test_utils.h"
9 #include "content/browser/utility_process_host_impl.h" 9 #include "content/browser/utility_process_host_impl.h"
10 #include "content/public/browser/utility_process_host_client.h" 10 #include "content/public/browser/utility_process_host_client.h"
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 int expected_id_; 235 int expected_id_;
236 std::vector<IndexedDBKey> expected_keys_; 236 std::vector<IndexedDBKey> expected_keys_;
237 base::WeakPtr<UtilityProcessHost> utility_process_host_; 237 base::WeakPtr<UtilityProcessHost> utility_process_host_;
238 bool value_for_key_path_failed_; 238 bool value_for_key_path_failed_;
239 SerializedScriptValue expected_value_; 239 SerializedScriptValue expected_value_;
240 }; 240 };
241 241
242 // This test fixture runs in the UI thread. However, most of the work done by 242 // This test fixture runs in the UI thread. However, most of the work done by
243 // UtilityProcessHost (and wrapped by IDBKeyPathHelper above) happens on the IO 243 // UtilityProcessHost (and wrapped by IDBKeyPathHelper above) happens on the IO
244 // thread. This fixture delegates to IDBKeyPathHelper and blocks via 244 // thread. This fixture delegates to IDBKeyPathHelper and blocks via
245 // "ui_test_utils::RunMessageLoop()", until IDBKeyPathHelper posts a quit 245 // "content::RunMessageLoop()", until IDBKeyPathHelper posts a quit
246 // message the MessageLoop. 246 // message the MessageLoop.
247 class ScopedIDBKeyPathHelper { 247 class ScopedIDBKeyPathHelper {
248 public: 248 public:
249 ScopedIDBKeyPathHelper() { 249 ScopedIDBKeyPathHelper() {
250 key_path_helper_ = new IDBKeyPathHelper(); 250 key_path_helper_ = new IDBKeyPathHelper();
251 key_path_helper_->CreateUtilityProcess(); 251 key_path_helper_->CreateUtilityProcess();
252 ui_test_utils::RunMessageLoop(); 252 content::RunMessageLoop();
253 } 253 }
254 254
255 ~ScopedIDBKeyPathHelper() { 255 ~ScopedIDBKeyPathHelper() {
256 key_path_helper_->DestroyUtilityProcess(); 256 key_path_helper_->DestroyUtilityProcess();
257 ui_test_utils::RunMessageLoop(); 257 content::RunMessageLoop();
258 } 258 }
259 259
260 void SetExpectedKeys(int id, 260 void SetExpectedKeys(int id,
261 const std::vector<IndexedDBKey>& expected_keys, 261 const std::vector<IndexedDBKey>& expected_keys,
262 bool failed) { 262 bool failed) {
263 key_path_helper_->SetExpectedKeys(id, expected_keys, failed); 263 key_path_helper_->SetExpectedKeys(id, expected_keys, failed);
264 } 264 }
265 265
266 void SetExpectedValue(const SerializedScriptValue& expected_value) { 266 void SetExpectedValue(const SerializedScriptValue& expected_value) {
267 key_path_helper_->SetExpectedValue(expected_value); 267 key_path_helper_->SetExpectedValue(expected_value);
268 } 268 }
269 269
270 void CheckValuesForKeyPath( 270 void CheckValuesForKeyPath(
271 int id, 271 int id,
272 const std::vector<SerializedScriptValue>& 272 const std::vector<SerializedScriptValue>&
273 serialized_script_values, 273 serialized_script_values,
274 const IndexedDBKeyPath& key_path) { 274 const IndexedDBKeyPath& key_path) {
275 key_path_helper_->CheckValuesForKeyPath(id, serialized_script_values, 275 key_path_helper_->CheckValuesForKeyPath(id, serialized_script_values,
276 key_path); 276 key_path);
277 ui_test_utils::RunMessageLoop(); 277 content::RunMessageLoop();
278 } 278 }
279 279
280 void CheckInjectValue(const IndexedDBKey& key, 280 void CheckInjectValue(const IndexedDBKey& key,
281 const SerializedScriptValue& value, 281 const SerializedScriptValue& value,
282 const IndexedDBKeyPath& key_path) { 282 const IndexedDBKeyPath& key_path) {
283 key_path_helper_->CheckInjectValue(key, value, key_path); 283 key_path_helper_->CheckInjectValue(key, value, key_path);
284 ui_test_utils::RunMessageLoop(); 284 content::RunMessageLoop();
285 } 285 }
286 286
287 private: 287 private:
288 scoped_refptr<IDBKeyPathHelper> key_path_helper_; 288 scoped_refptr<IDBKeyPathHelper> key_path_helper_;
289 }; 289 };
290 290
291 // Cases: 291 // Cases:
292 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, IDBKeyPathExtract) { 292 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, IDBKeyPathExtract) {
293 ScopedIDBKeyPathHelper scoped_helper; 293 ScopedIDBKeyPathHelper scoped_helper;
294 const int kId = 7; 294 const int kId = 7;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 0x5301, 0x6203, 0x7261, 0x013f, 0x3f6f, 432 0x5301, 0x6203, 0x7261, 0x013f, 0x3f6f,
433 0x5302, 0x6203, 0x7a61, 0x023f, 0x0853, 433 0x5302, 0x6203, 0x7a61, 0x023f, 0x0853,
434 0x796d, 0x654e, 0x4b77, 0x7965, 0x017b, 434 0x796d, 0x654e, 0x4b77, 0x7965, 0x017b,
435 0x027b}; 435 0x027b};
436 SerializedScriptValue expected_value2( 436 SerializedScriptValue expected_value2(
437 false, false, string16(expected_data2, arraysize(expected_data2))); 437 false, false, string16(expected_data2, arraysize(expected_data2)));
438 scoped_helper.SetExpectedValue(expected_value2); 438 scoped_helper.SetExpectedValue(expected_value2);
439 key_path.SetString(UTF8ToUTF16("bar.baz")); 439 key_path.SetString(UTF8ToUTF16("bar.baz"));
440 scoped_helper.CheckInjectValue(key, value, key_path); 440 scoped_helper.CheckInjectValue(key, value, key_path);
441 } 441 }
OLDNEW
« no previous file with comments | « content/browser/download/mhtml_generation_browsertest.cc ('k') | content/browser/plugin_data_remover_impl_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698