Chromium Code Reviews

Side by Side Diff: chrome/browser/password_manager/password_store_x_unittest.cc

Issue 5448001: Remove duplicate NotificationObserver mock. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/scoped_temp_dir.h" 6 #include "base/scoped_temp_dir.h"
7 #include "base/stl_util-inl.h" 7 #include "base/stl_util-inl.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "base/waitable_event.h" 10 #include "base/waitable_event.h"
11 #include "chrome/browser/password_manager/password_form_data.h" 11 #include "chrome/browser/password_manager/password_form_data.h"
12 #include "chrome/browser/password_manager/password_store_change.h" 12 #include "chrome/browser/password_manager/password_store_change.h"
13 #include "chrome/browser/password_manager/password_store_x.h" 13 #include "chrome/browser/password_manager/password_store_x.h"
14 #include "chrome/browser/webdata/web_data_service.h" 14 #include "chrome/browser/webdata/web_data_service.h"
15 #include "chrome/common/notification_observer_mock.h"
15 #include "chrome/common/notification_service.h" 16 #include "chrome/common/notification_service.h"
16 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
17 #include "chrome/test/mock_notification_observer.h"
18 #include "chrome/test/signaling_task.h" 18 #include "chrome/test/signaling_task.h"
19 #include "chrome/test/testing_profile.h" 19 #include "chrome/test/testing_profile.h"
20 #include "testing/gmock/include/gmock/gmock.h" 20 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 22
23 using base::WaitableEvent; 23 using base::WaitableEvent;
24 using testing::_; 24 using testing::_;
25 using testing::DoAll; 25 using testing::DoAll;
26 using testing::ElementsAreArray; 26 using testing::ElementsAreArray;
27 using testing::Pointee; 27 using testing::Pointee;
(...skipping 32 matching lines...)
60 FROM_HERE, 60 FROM_HERE,
61 NewRunnableMethod(this, &DBThreadObserverHelper::AddObserverTask)); 61 NewRunnableMethod(this, &DBThreadObserverHelper::AddObserverTask));
62 done_event_.Wait(); 62 done_event_.Wait();
63 } 63 }
64 64
65 virtual ~DBThreadObserverHelper() { 65 virtual ~DBThreadObserverHelper() {
66 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 66 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
67 registrar_.RemoveAll(); 67 registrar_.RemoveAll();
68 } 68 }
69 69
70 MockNotificationObserver& observer() { 70 NotificationObserverMock& observer() {
71 return observer_; 71 return observer_;
72 } 72 }
73 73
74 protected: 74 protected:
75 friend class base::RefCountedThreadSafe<DBThreadObserverHelper>; 75 friend class base::RefCountedThreadSafe<DBThreadObserverHelper>;
76 76
77 void AddObserverTask() { 77 void AddObserverTask() {
78 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 78 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
79 registrar_.Add(&observer_, 79 registrar_.Add(&observer_,
80 NotificationType::LOGINS_CHANGED, 80 NotificationType::LOGINS_CHANGED,
81 NotificationService::AllSources()); 81 NotificationService::AllSources());
82 done_event_.Signal(); 82 done_event_.Signal();
83 } 83 }
84 84
85 WaitableEvent done_event_; 85 WaitableEvent done_event_;
86 NotificationRegistrar registrar_; 86 NotificationRegistrar registrar_;
87 MockNotificationObserver observer_; 87 NotificationObserverMock observer_;
88 }; 88 };
89 89
90 class FailingBackend : public PasswordStoreX::NativeBackend { 90 class FailingBackend : public PasswordStoreX::NativeBackend {
91 public: 91 public:
92 virtual bool Init() { return true; } 92 virtual bool Init() { return true; }
93 93
94 virtual bool AddLogin(const PasswordForm& form) { return false; } 94 virtual bool AddLogin(const PasswordForm& form) { return false; }
95 virtual bool UpdateLogin(const PasswordForm& form) { return false; } 95 virtual bool UpdateLogin(const PasswordForm& form) { return false; }
96 virtual bool RemoveLogin(const PasswordForm& form) { return false; } 96 virtual bool RemoveLogin(const PasswordForm& form) { return false; }
97 97
(...skipping 635 matching lines...)
733 733
734 INSTANTIATE_TEST_CASE_P(NoBackend, 734 INSTANTIATE_TEST_CASE_P(NoBackend,
735 PasswordStoreXTest, 735 PasswordStoreXTest,
736 testing::Values(NO_BACKEND)); 736 testing::Values(NO_BACKEND));
737 INSTANTIATE_TEST_CASE_P(FailingBackend, 737 INSTANTIATE_TEST_CASE_P(FailingBackend,
738 PasswordStoreXTest, 738 PasswordStoreXTest,
739 testing::Values(FAILING_BACKEND)); 739 testing::Values(FAILING_BACKEND));
740 INSTANTIATE_TEST_CASE_P(WorkingBackend, 740 INSTANTIATE_TEST_CASE_P(WorkingBackend,
741 PasswordStoreXTest, 741 PasswordStoreXTest,
742 testing::Values(WORKING_BACKEND)); 742 testing::Values(WORKING_BACKEND));
OLDNEW

Powered by Google App Engine