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

Unified Diff: components/autofill/browser/autofill_manager_unittest.cc

Issue 14096008: Use content::MessageLoopRunner in a couple of Autofill tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/autofill/browser/autofill_metrics_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/browser/autofill_manager_unittest.cc
diff --git a/components/autofill/browser/autofill_manager_unittest.cc b/components/autofill/browser/autofill_manager_unittest.cc
index 0daffb015da2125112276af55da702fbb6fdb233..3fede5cb1703f8a6db05ca420a86cfd889ceedcd 100644
--- a/components/autofill/browser/autofill_manager_unittest.cc
+++ b/components/autofill/browser/autofill_manager_unittest.cc
@@ -41,6 +41,7 @@
#include "content/public/browser/web_contents.h"
#include "content/public/test/mock_render_process_host.h"
#include "content/public/test/test_browser_thread.h"
+#include "content/public/test/test_utils.h"
#include "googleurl/src/gurl.h"
#include "grit/generated_resources.h"
#include "ipc/ipc_test_sink.h"
@@ -484,10 +485,7 @@ class TestAutofillManager : public AutofillManager {
TestPersonalDataManager* personal_data)
: AutofillManager(web_contents, delegate, personal_data),
personal_data_(personal_data),
- autofill_enabled_(true),
- did_finish_async_form_submit_(false),
- message_loop_is_running_(false) {
- }
+ autofill_enabled_(true) {}
virtual ~TestAutofillManager() {}
virtual bool IsAutofillEnabled() const OVERRIDE { return autofill_enabled_; }
@@ -520,12 +518,7 @@ class TestAutofillManager : public AutofillManager {
const base::TimeTicks& load_time,
const base::TimeTicks& interaction_time,
const base::TimeTicks& submission_time) OVERRIDE {
- if (message_loop_is_running_) {
- MessageLoop::current()->Quit();
- message_loop_is_running_ = false;
- } else {
- did_finish_async_form_submit_ = true;
- }
+ message_loop_runner_->Quit();
// If we have expected field types set, make sure they match.
if (!expected_submitted_field_types_.empty()) {
@@ -555,16 +548,15 @@ class TestAutofillManager : public AutofillManager {
submission_time);
}
+ // Resets the MessageLoopRunner so that it can way for an asynchronous form
groby-ooo-7-16 2013/04/15 22:19:20 nit: "wait for"
Ilya Sherman 2013/04/16 00:57:53 Done.
+ // submission to complete.
+ void ResetMessageLoopRunner() {
+ message_loop_runner_ = new content::MessageLoopRunner();
+ }
+
// Wait for the asynchronous OnFormSubmitted() call to complete.
void WaitForAsyncFormSubmit() {
- if (!did_finish_async_form_submit_) {
- // TODO(isherman): It seems silly to need this variable. Is there some
- // way I can just query the message loop's state?
- message_loop_is_running_ = true;
- MessageLoop::current()->Run();
- } else {
- did_finish_async_form_submit_ = false;
- }
+ message_loop_runner_->Run();
}
virtual void UploadFormData(const FormStructure& submitted_form) OVERRIDE {
@@ -633,8 +625,7 @@ class TestAutofillManager : public AutofillManager {
std::vector<std::pair<WebFormElement::AutocompleteResult, FormData> >
request_autocomplete_results_;
- bool did_finish_async_form_submit_;
- bool message_loop_is_running_;
+ scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
std::string autocheckout_url_prefix_;
std::string submitted_form_signature_;
@@ -731,6 +722,7 @@ class AutofillManagerTest : public ChromeRenderViewHostTestHarness {
}
void FormSubmitted(const FormData& form) {
+ autofill_manager_->ResetMessageLoopRunner();
if (autofill_manager_->OnFormSubmitted(form, base::TimeTicks::Now()))
autofill_manager_->WaitForAsyncFormSubmit();
}
« no previous file with comments | « no previous file | components/autofill/browser/autofill_metrics_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698