This source file includes following definitions.
- password_number_
- AddLogins
- UpdateLogins
- RemoveLogins
- NextLogin
- NextPassword
- IN_PROC_BROWSER_TEST_F
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/sync/test/integration/passwords_helper.h"
#include "chrome/browser/sync/test/integration/performance/sync_timing_helper.h"
#include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
#include "chrome/browser/sync/test/integration/sync_test.h"
#include "components/password_manager/core/browser/password_store.h"
using passwords_helper::AddLogin;
using passwords_helper::CreateTestPasswordForm;
using passwords_helper::GetLogins;
using passwords_helper::GetPasswordCount;
using passwords_helper::GetPasswordStore;
using passwords_helper::UpdateLogin;
static const int kNumPasswords = 150;
class PasswordsSyncPerfTest : public SyncTest {
public:
PasswordsSyncPerfTest() : SyncTest(TWO_CLIENT), password_number_(0) {}
void AddLogins(int profile, int num_logins);
void UpdateLogins(int profile);
void RemoveLogins(int profile);
private:
autofill::PasswordForm NextLogin();
std::string NextPassword();
int password_number_;
DISALLOW_COPY_AND_ASSIGN(PasswordsSyncPerfTest);
};
void PasswordsSyncPerfTest::AddLogins(int profile, int num_logins) {
for (int i = 0; i < num_logins; ++i) {
AddLogin(GetPasswordStore(profile), NextLogin());
}
}
void PasswordsSyncPerfTest::UpdateLogins(int profile) {
std::vector<autofill::PasswordForm> logins;
GetLogins(GetPasswordStore(profile), logins);
for (std::vector<autofill::PasswordForm>::iterator it = logins.begin();
it != logins.end(); ++it) {
(*it).password_value = base::ASCIIToUTF16(NextPassword());
UpdateLogin(GetPasswordStore(profile), (*it));
}
}
void PasswordsSyncPerfTest::RemoveLogins(int profile) {
passwords_helper::RemoveLogins(GetPasswordStore(profile));
}
autofill::PasswordForm PasswordsSyncPerfTest::NextLogin() {
return CreateTestPasswordForm(password_number_++);
}
std::string PasswordsSyncPerfTest::NextPassword() {
return base::StringPrintf("password%d", password_number_++);
}
#if defined(OS_WIN)
#define MAYBE_P0 DISABLED_P0
#else
#define MAYBE_P0 P0
#endif
IN_PROC_BROWSER_TEST_F(PasswordsSyncPerfTest, MAYBE_P0) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
AddLogins(0, kNumPasswords);
base::TimeDelta dt = SyncTimingHelper::TimeUntilQuiescence(clients());
ASSERT_EQ(kNumPasswords, GetPasswordCount(1));
SyncTimingHelper::PrintResult("passwords", "add_passwords", dt);
UpdateLogins(0);
dt = SyncTimingHelper::TimeUntilQuiescence(clients());
ASSERT_EQ(kNumPasswords, GetPasswordCount(1));
SyncTimingHelper::PrintResult("passwords", "update_passwords", dt);
RemoveLogins(0);
dt = SyncTimingHelper::TimeUntilQuiescence(clients());
ASSERT_EQ(0, GetPasswordCount(1));
SyncTimingHelper::PrintResult("passwords", "delete_passwords", dt);
}