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

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

Issue 10494012: Move mock notification observer header from content\test to content\public\test. This way we can en… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/stl_util.h" 7 #include "base/stl_util.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
10 #include "base/time.h" 10 #include "base/time.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_consumer.h" 12 #include "chrome/browser/password_manager/password_store_consumer.h"
13 #include "chrome/browser/password_manager/password_store_default.h" 13 #include "chrome/browser/password_manager/password_store_default.h"
14 #include "chrome/common/chrome_notification_types.h" 14 #include "chrome/common/chrome_notification_types.h"
15 #include "chrome/test/base/testing_profile.h" 15 #include "chrome/test/base/testing_profile.h"
16 #include "content/public/browser/notification_details.h" 16 #include "content/public/browser/notification_details.h"
17 #include "content/public/browser/notification_registrar.h" 17 #include "content/public/browser/notification_registrar.h"
18 #include "content/public/browser/notification_source.h" 18 #include "content/public/browser/notification_source.h"
19 #include "content/test/notification_observer_mock.h" 19 #include "content/public/test/mock_notification_observer.h"
20 #include "content/test/test_browser_thread.h" 20 #include "content/test/test_browser_thread.h"
21 #include "testing/gmock/include/gmock/gmock.h" 21 #include "testing/gmock/include/gmock/gmock.h"
22 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
23 23
24 using base::WaitableEvent; 24 using base::WaitableEvent;
25 using content::BrowserThread; 25 using content::BrowserThread;
26 using testing::_; 26 using testing::_;
27 using testing::DoAll; 27 using testing::DoAll;
28 using testing::WithArg; 28 using testing::WithArg;
29 using webkit::forms::PasswordForm; 29 using webkit::forms::PasswordForm;
(...skipping 19 matching lines...) Expand all
49 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 49 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
50 BrowserThread::PostTask( 50 BrowserThread::PostTask(
51 BrowserThread::DB, 51 BrowserThread::DB,
52 FROM_HERE, 52 FROM_HERE,
53 base::Bind(&DBThreadObserverHelper::AddObserverTask, 53 base::Bind(&DBThreadObserverHelper::AddObserverTask,
54 this, 54 this,
55 make_scoped_refptr(password_store))); 55 make_scoped_refptr(password_store)));
56 done_event_.Wait(); 56 done_event_.Wait();
57 } 57 }
58 58
59 content::NotificationObserverMock& observer() { 59 content::MockNotificationObserver& observer() {
60 return observer_; 60 return observer_;
61 } 61 }
62 62
63 protected: 63 protected:
64 virtual ~DBThreadObserverHelper() { 64 virtual ~DBThreadObserverHelper() {
65 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 65 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
66 registrar_.RemoveAll(); 66 registrar_.RemoveAll();
67 } 67 }
68 68
69 void AddObserverTask(PasswordStore* password_store) { 69 void AddObserverTask(PasswordStore* password_store) {
70 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 70 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
71 registrar_.Add(&observer_, 71 registrar_.Add(&observer_,
72 chrome::NOTIFICATION_LOGINS_CHANGED, 72 chrome::NOTIFICATION_LOGINS_CHANGED,
73 content::Source<PasswordStore>(password_store)); 73 content::Source<PasswordStore>(password_store));
74 done_event_.Signal(); 74 done_event_.Signal();
75 } 75 }
76 76
77 WaitableEvent done_event_; 77 WaitableEvent done_event_;
78 content::NotificationRegistrar registrar_; 78 content::NotificationRegistrar registrar_;
79 content::NotificationObserverMock observer_; 79 content::MockNotificationObserver observer_;
80 80
81 private: 81 private:
82 friend struct BrowserThread::DeleteOnThread<BrowserThread::DB>; 82 friend struct BrowserThread::DeleteOnThread<BrowserThread::DB>;
83 friend class base::DeleteHelper<DBThreadObserverHelper>; 83 friend class base::DeleteHelper<DBThreadObserverHelper>;
84 }; 84 };
85 85
86 } // anonymous namespace 86 } // anonymous namespace
87 87
88 class PasswordStoreTest : public testing::Test { 88 class PasswordStoreTest : public testing::Test {
89 protected: 89 protected:
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 .WillOnce(WithArg<1>(STLDeleteElements0())).RetiresOnSaturation(); 258 .WillOnce(WithArg<1>(STLDeleteElements0())).RetiresOnSaturation();
259 259
260 store->GetLogins(www_google, &consumer); 260 store->GetLogins(www_google, &consumer);
261 store->GetLogins(accounts_google, &consumer); 261 store->GetLogins(accounts_google, &consumer);
262 store->GetLogins(bar_example, &consumer); 262 store->GetLogins(bar_example, &consumer);
263 263
264 MessageLoop::current()->Run(); 264 MessageLoop::current()->Run();
265 265
266 STLDeleteElements(&all_forms); 266 STLDeleteElements(&all_forms);
267 } 267 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698