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

Unified Diff: chrome/browser/password_manager/password_store_default_unittest.cc

Issue 8274012: Wait for URLBlacklist update tasks on automation tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added BrowserThread::WaitForPendingTasksOn, removed SignalingTask Created 9 years, 2 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
Index: chrome/browser/password_manager/password_store_default_unittest.cc
diff --git a/chrome/browser/password_manager/password_store_default_unittest.cc b/chrome/browser/password_manager/password_store_default_unittest.cc
index db6b8b0bcb0a3132902e0ad075d9b03a9b3a10e8..e5ec4f238d3df6b5340db901132281210ab4a244 100644
--- a/chrome/browser/password_manager/password_store_default_unittest.cc
+++ b/chrome/browser/password_manager/password_store_default_unittest.cc
@@ -6,7 +6,6 @@
#include "base/scoped_temp_dir.h"
#include "base/stl_util.h"
#include "base/string_util.h"
-#include "base/synchronization/waitable_event.h"
#include "base/time.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/password_manager/password_form_data.h"
@@ -17,7 +16,6 @@
#include "chrome/browser/webdata/web_data_service.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/pref_names.h"
-#include "chrome/test/base/signaling_task.h"
#include "chrome/test/base/testing_profile.h"
#include "content/common/notification_details.h"
#include "content/common/notification_observer_mock.h"
@@ -26,7 +24,6 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-using base::WaitableEvent;
using testing::_;
using testing::DoAll;
using testing::ElementsAreArray;
@@ -56,7 +53,7 @@ class DBThreadObserverHelper :
public base::RefCountedThreadSafe<DBThreadObserverHelper,
BrowserThread::DeleteOnDBThread> {
public:
- DBThreadObserverHelper() : done_event_(true, false) {}
+ DBThreadObserverHelper() {}
void Init(PasswordStore* password_store) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -66,7 +63,7 @@ class DBThreadObserverHelper :
NewRunnableMethod(this,
&DBThreadObserverHelper::AddObserverTask,
make_scoped_refptr(password_store)));
- done_event_.Wait();
+ CHECK(BrowserThread::WaitForPendingTasksOn(BrowserThread::DB));
}
virtual ~DBThreadObserverHelper() {
@@ -86,10 +83,8 @@ class DBThreadObserverHelper :
registrar_.Add(&observer_,
chrome::NOTIFICATION_LOGINS_CHANGED,
Source<PasswordStore>(password_store));
- done_event_.Signal();
}
- WaitableEvent done_event_;
NotificationRegistrar registrar_;
NotificationObserverMock observer_;
};
@@ -186,10 +181,7 @@ TEST_F(PasswordStoreDefaultTest, NonASCIIData) {
// The PasswordStore schedules tasks to run on the DB thread so we schedule
// yet another task to notify us that it's safe to carry on with the test.
- WaitableEvent done(false, false);
- BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
- new SignalingTask(&done));
- done.Wait();
+ CHECK(BrowserThread::WaitForPendingTasksOn(BrowserThread::DB));
MockPasswordStoreConsumer consumer;
@@ -281,10 +273,7 @@ TEST_F(PasswordStoreDefaultTest, Migration) {
// The WDS schedules tasks to run on the DB thread so we schedule yet another
// task to notify us that it's safe to carry on with the test.
- WaitableEvent done(false, false);
- BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
- new SignalingTask(&done));
- done.Wait();
+ CHECK(BrowserThread::WaitForPendingTasksOn(BrowserThread::DB));
// Initializing the PasswordStore should trigger a migration.
scoped_refptr<PasswordStore> store(
@@ -298,9 +287,7 @@ TEST_F(PasswordStoreDefaultTest, Migration) {
// Again, the WDS schedules tasks to run on the DB thread, so schedule a task
// to signal us when it is safe to continue.
- BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
- new SignalingTask(&done));
- done.Wait();
+ CHECK(BrowserThread::WaitForPendingTasksOn(BrowserThread::DB));
// Let the WDS callbacks proceed so the logins can be migrated.
MessageLoop::current()->RunAllPending();
@@ -343,9 +330,7 @@ TEST_F(PasswordStoreDefaultTest, Migration) {
wds_->GetAutofillableLogins(&wds_consumer);
// Wait for the WDS methods to execute on the DB thread.
- BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
- new SignalingTask(&done));
- done.Wait();
+ CHECK(BrowserThread::WaitForPendingTasksOn(BrowserThread::DB));
// Handle the callback from the WDS.
MessageLoop::current()->RunAllPending();
@@ -357,9 +342,7 @@ TEST_F(PasswordStoreDefaultTest, Migration) {
wds_->GetBlacklistLogins(&wds_consumer);
// Wait for the WDS methods to execute on the DB thread.
- BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
- new SignalingTask(&done));
- done.Wait();
+ CHECK(BrowserThread::WaitForPendingTasksOn(BrowserThread::DB));
// Handle the callback from the WDS.
MessageLoop::current()->RunAllPending();
@@ -394,10 +377,7 @@ TEST_F(PasswordStoreDefaultTest, MigrationAlreadyDone) {
// The WDS schedules tasks to run on the DB thread so we schedule yet another
// task to notify us that it's safe to carry on with the test.
- WaitableEvent done(false, false);
- BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
- new SignalingTask(&done));
- done.Wait();
+ CHECK(BrowserThread::WaitForPendingTasksOn(BrowserThread::DB));
// Pretend that the migration has already taken place.
profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated,
@@ -474,10 +454,7 @@ TEST_F(PasswordStoreDefaultTest, Notifications) {
// The PasswordStore schedules tasks to run on the DB thread so we schedule
// yet another task to notify us that it's safe to carry on with the test.
- WaitableEvent done(false, false);
- BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
- new SignalingTask(&done));
- done.Wait();
+ CHECK(BrowserThread::WaitForPendingTasksOn(BrowserThread::DB));
// Change the password.
form->password_value = WideToUTF16(L"a different password");
@@ -497,9 +474,7 @@ TEST_F(PasswordStoreDefaultTest, Notifications) {
store->UpdateLogin(*form);
// Wait for PasswordStore to send the notification.
- BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
- new SignalingTask(&done));
- done.Wait();
+ CHECK(BrowserThread::WaitForPendingTasksOn(BrowserThread::DB));
const PasswordStoreChange expected_delete_changes[] = {
PasswordStoreChange(PasswordStoreChange::REMOVE, *form),
@@ -516,9 +491,7 @@ TEST_F(PasswordStoreDefaultTest, Notifications) {
store->RemoveLogin(*form);
// Wait for PasswordStore to send the notification.
- BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
- new SignalingTask(&done));
- done.Wait();
+ CHECK(BrowserThread::WaitForPendingTasksOn(BrowserThread::DB));
store->Shutdown();
}

Powered by Google App Engine
This is Rietveld 408576698