1// Copyright (c) 2011 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "chrome/browser/sync/profile_sync_service.h"
6#include "chrome/browser/sync/test/integration/passwords_helper.h"
7#include "chrome/browser/sync/test/integration/sync_integration_test_util.h"
8#include "chrome/browser/sync/test/integration/sync_test.h"
9#include "components/password_manager/core/browser/password_form_data.h"
10
11using passwords_helper::AddLogin;
12using passwords_helper::CreateTestPasswordForm;
13using passwords_helper::GetPasswordCount;
14using passwords_helper::GetPasswordStore;
15using passwords_helper::GetVerifierPasswordCount;
16using passwords_helper::GetVerifierPasswordStore;
17using passwords_helper::ProfileContainsSamePasswordFormsAsVerifier;
18using sync_integration_test_util::AwaitCommitActivityCompletion;
19
20using autofill::PasswordForm;
21
22class SingleClientPasswordsSyncTest : public SyncTest {
23 public:
24  SingleClientPasswordsSyncTest() : SyncTest(SINGLE_CLIENT) {}
25  virtual ~SingleClientPasswordsSyncTest() {}
26
27 private:
28  DISALLOW_COPY_AND_ASSIGN(SingleClientPasswordsSyncTest);
29};
30
31IN_PROC_BROWSER_TEST_F(SingleClientPasswordsSyncTest, Sanity) {
32  ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
33
34  PasswordForm form = CreateTestPasswordForm(0);
35  AddLogin(GetVerifierPasswordStore(), form);
36  ASSERT_EQ(1, GetVerifierPasswordCount());
37  AddLogin(GetPasswordStore(0), form);
38  ASSERT_EQ(1, GetPasswordCount(0));
39
40  ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0))));
41  ASSERT_TRUE(ProfileContainsSamePasswordFormsAsVerifier(0));
42  ASSERT_EQ(1, GetPasswordCount(0));
43}
44