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

Unified Diff: chrome/browser/password_manager/password_store_x_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_x_unittest.cc
diff --git a/chrome/browser/password_manager/password_store_x_unittest.cc b/chrome/browser/password_manager/password_store_x_unittest.cc
index 495f8d50a1a7581d60b65feecd740627e450e4af..031551ff6d81929482c4ca5d2e21710f27fb6fe8 100644
--- a/chrome/browser/password_manager/password_store_x_unittest.cc
+++ b/chrome/browser/password_manager/password_store_x_unittest.cc
@@ -10,7 +10,6 @@
#include "base/stl_util.h"
#include "base/string_util.h"
#include "base/stringprintf.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"
@@ -21,7 +20,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_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "content/common/notification_details.h"
@@ -31,7 +29,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;
@@ -63,7 +60,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));
@@ -72,7 +69,7 @@ class DBThreadObserverHelper
FROM_HERE,
base::Bind(&DBThreadObserverHelper::AddObserverTask,
this, make_scoped_refptr(password_store)));
- done_event_.Wait();
+ CHECK(BrowserThread::WaitForPendingTasksOn(BrowserThread::DB));
}
virtual ~DBThreadObserverHelper() {
@@ -92,10 +89,8 @@ class DBThreadObserverHelper
registrar_.Add(&observer_,
chrome::NOTIFICATION_LOGINS_CHANGED,
Source<PasswordStore>(password_store));
- done_event_.Signal();
}
- WaitableEvent done_event_;
NotificationRegistrar registrar_;
NotificationObserverMock observer_;
};
@@ -355,10 +350,7 @@ TEST_P(PasswordStoreXTest, WDSMigration) {
// 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<PasswordStoreX> store(
@@ -374,9 +366,7 @@ TEST_P(PasswordStoreXTest, WDSMigration) {
// 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();
@@ -419,9 +409,7 @@ TEST_P(PasswordStoreXTest, WDSMigration) {
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();
@@ -433,9 +421,7 @@ TEST_P(PasswordStoreXTest, WDSMigration) {
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();
@@ -475,10 +461,7 @@ TEST_P(PasswordStoreXTest, WDSMigrationAlreadyDone) {
// 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,
@@ -560,10 +543,7 @@ TEST_P(PasswordStoreXTest, 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");
@@ -583,9 +563,7 @@ TEST_P(PasswordStoreXTest, 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),
@@ -602,9 +580,7 @@ TEST_P(PasswordStoreXTest, 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));
// Public in PasswordStore, protected in PasswordStoreX.
static_cast<PasswordStore*>(store)->Shutdown();
@@ -643,10 +619,7 @@ TEST_P(PasswordStoreXTest, NativeMigration) {
// Schedule another task on the DB thread 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));
// Get the new size of the login DB file. We expect it to be larger.
base::PlatformFileInfo db_file_full_info;
@@ -709,9 +682,7 @@ TEST_P(PasswordStoreXTest, NativeMigration) {
new LoginDatabaseQueryTask(login_db, true, &ld_return));
// Wait for the login DB methods to execute on the DB thread.
- BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
- new SignalingTask(&done));
- done.Wait();
+ CHECK(BrowserThread::WaitForPendingTasksOn(BrowserThread::DB));
if (GetParam() == WORKING_BACKEND) {
// Likewise, no blacklisted logins should be left in the login DB.
@@ -729,9 +700,7 @@ TEST_P(PasswordStoreXTest, NativeMigration) {
new LoginDatabaseQueryTask(login_db, false, &ld_return));
// Wait for the login DB methods to execute on the DB thread.
- BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
- new SignalingTask(&done));
- done.Wait();
+ CHECK(BrowserThread::WaitForPendingTasksOn(BrowserThread::DB));
if (GetParam() == WORKING_BACKEND) {
// If the migration succeeded, then not only should there be no logins left

Powered by Google App Engine
This is Rietveld 408576698