| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
| 8 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 9 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| 10 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 12 #include "base/synchronization/waitable_event.h" | 13 #include "base/synchronization/waitable_event.h" |
| 13 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 14 #include "chrome/test/base/testing_profile.h" | |
| 15 #include "components/password_manager/core/browser/password_form_data.h" | 15 #include "components/password_manager/core/browser/password_form_data.h" |
| 16 #include "components/password_manager/core/browser/password_store_change.h" | 16 #include "components/password_manager/core/browser/password_store_change.h" |
| 17 #include "components/password_manager/core/browser/password_store_consumer.h" | 17 #include "components/password_manager/core/browser/password_store_consumer.h" |
| 18 #include "components/password_manager/core/browser/password_store_default.h" | 18 #include "components/password_manager/core/browser/password_store_default.h" |
| 19 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 21 | 21 |
| 22 using autofill::PasswordForm; | 22 using autofill::PasswordForm; |
| 23 using base::WaitableEvent; | 23 using base::WaitableEvent; |
| 24 using testing::_; | 24 using testing::_; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 39 class MockPasswordStoreObserver : public PasswordStore::Observer { | 39 class MockPasswordStoreObserver : public PasswordStore::Observer { |
| 40 public: | 40 public: |
| 41 MOCK_METHOD1(OnLoginsChanged, | 41 MOCK_METHOD1(OnLoginsChanged, |
| 42 void(const PasswordStoreChangeList& changes)); | 42 void(const PasswordStoreChangeList& changes)); |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 } // anonymous namespace | 45 } // anonymous namespace |
| 46 | 46 |
| 47 class PasswordStoreDefaultTest : public testing::Test { | 47 class PasswordStoreDefaultTest : public testing::Test { |
| 48 protected: | 48 protected: |
| 49 virtual void SetUp() { | 49 virtual void SetUp() OVERRIDE { |
| 50 profile_.reset(new TestingProfile()); | 50 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 51 login_db_.reset(new LoginDatabase()); |
| 52 ASSERT_TRUE(login_db_->Init(temp_dir_.path().Append( |
| 53 FILE_PATH_LITERAL("login_test")))); |
| 54 } |
| 51 | 55 |
| 52 login_db_.reset(new LoginDatabase()); | 56 virtual void TearDown() OVERRIDE { |
| 53 ASSERT_TRUE(login_db_->Init(profile_->GetPath().Append( | 57 ASSERT_TRUE(temp_dir_.Delete()); |
| 54 FILE_PATH_LITERAL("login_test")))); | |
| 55 } | 58 } |
| 56 | 59 |
| 57 base::MessageLoopForUI message_loop_; | 60 base::MessageLoopForUI message_loop_; |
| 58 scoped_ptr<LoginDatabase> login_db_; | 61 scoped_ptr<LoginDatabase> login_db_; |
| 59 scoped_ptr<TestingProfile> profile_; | 62 base::ScopedTempDir temp_dir_; |
| 60 }; | 63 }; |
| 61 | 64 |
| 62 ACTION(STLDeleteElements0) { | 65 ACTION(STLDeleteElements0) { |
| 63 STLDeleteContainerPointers(arg0.begin(), arg0.end()); | 66 STLDeleteContainerPointers(arg0.begin(), arg0.end()); |
| 64 } | 67 } |
| 65 | 68 |
| 66 TEST_F(PasswordStoreDefaultTest, NonASCIIData) { | 69 TEST_F(PasswordStoreDefaultTest, NonASCIIData) { |
| 67 scoped_refptr<PasswordStoreDefault> store(new PasswordStoreDefault( | 70 scoped_refptr<PasswordStoreDefault> store(new PasswordStoreDefault( |
| 68 base::MessageLoopProxy::current(), | 71 base::MessageLoopProxy::current(), |
| 69 base::MessageLoopProxy::current(), | 72 base::MessageLoopProxy::current(), |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 observer, | 169 observer, |
| 167 OnLoginsChanged(ElementsAreArray(expected_delete_changes))); | 170 OnLoginsChanged(ElementsAreArray(expected_delete_changes))); |
| 168 | 171 |
| 169 // Deleting the login should trigger a notification. | 172 // Deleting the login should trigger a notification. |
| 170 store->RemoveLogin(*form); | 173 store->RemoveLogin(*form); |
| 171 base::MessageLoop::current()->RunUntilIdle(); | 174 base::MessageLoop::current()->RunUntilIdle(); |
| 172 | 175 |
| 173 store->RemoveObserver(&observer); | 176 store->RemoveObserver(&observer); |
| 174 store->Shutdown(); | 177 store->Shutdown(); |
| 175 } | 178 } |
| OLD | NEW |