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

Side by Side Diff: chrome/browser/webdata/web_data_service_unittest.cc

Issue 12853004: Move creation of WebDatabaseTable subclasses to WebDatabaseServiceFactory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix merge error. Created 7 years, 9 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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "base/message_loop.h" 13 #include "base/message_loop.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 #include "base/string16.h" 15 #include "base/string16.h"
16 #include "base/string_util.h" 16 #include "base/string_util.h"
17 #include "base/synchronization/waitable_event.h" 17 #include "base/synchronization/waitable_event.h"
18 #include "base/time.h" 18 #include "base/time.h"
19 #include "base/utf_string_conversions.h" 19 #include "base/utf_string_conversions.h"
20 #include "chrome/browser/webdata/autofill_change.h" 20 #include "chrome/browser/webdata/autofill_change.h"
21 #include "chrome/browser/webdata/autofill_entry.h" 21 #include "chrome/browser/webdata/autofill_entry.h"
22 #include "chrome/browser/webdata/autofill_table.h"
22 #include "chrome/browser/webdata/web_data_service.h" 23 #include "chrome/browser/webdata/web_data_service.h"
23 #include "chrome/browser/webdata/web_data_service_test_util.h" 24 #include "chrome/browser/webdata/web_data_service_test_util.h"
24 #include "chrome/common/chrome_notification_types.h" 25 #include "chrome/common/chrome_notification_types.h"
25 #include "chrome/test/base/thread_observer_helper.h" 26 #include "chrome/test/base/thread_observer_helper.h"
26 #include "components/autofill/browser/autofill_profile.h" 27 #include "components/autofill/browser/autofill_profile.h"
27 #include "components/autofill/browser/credit_card.h" 28 #include "components/autofill/browser/credit_card.h"
28 #include "components/autofill/common/form_field_data.h" 29 #include "components/autofill/common/form_field_data.h"
29 #include "content/public/browser/notification_details.h" 30 #include "content/public/browser/notification_details.h"
30 #include "content/public/browser/notification_service.h" 31 #include "content/public/browser/notification_service.h"
31 #include "content/public/test/test_browser_thread.h" 32 #include "content/public/test/test_browser_thread.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 public: 69 public:
69 WebDataServiceTest() 70 WebDataServiceTest()
70 : ui_thread_(BrowserThread::UI, &message_loop_), 71 : ui_thread_(BrowserThread::UI, &message_loop_),
71 db_thread_(BrowserThread::DB) {} 72 db_thread_(BrowserThread::DB) {}
72 73
73 protected: 74 protected:
74 virtual void SetUp() { 75 virtual void SetUp() {
75 db_thread_.Start(); 76 db_thread_.Start();
76 77
77 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 78 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
78 wds_ = new WebDataService(WebDataServiceBase::ProfileErrorCallback());
79 base::FilePath path = temp_dir_.path().AppendASCII("TestWebDB"); 79 base::FilePath path = temp_dir_.path().AppendASCII("TestWebDB");
80 wds_->Init(path); 80 wds_ = new WebDataService(path, WebDataServiceBase::ProfileErrorCallback());
81 // Need to add at least one table so the database gets created.
82 wds_->AddTable(scoped_ptr<WebDatabaseTable>(new AutofillTable).Pass());
83 wds_->Init();
81 } 84 }
82 85
83 virtual void TearDown() { 86 virtual void TearDown() {
84 wds_->ShutdownOnUIThread(); 87 wds_->ShutdownOnUIThread();
85 wds_ = NULL; 88 wds_ = NULL;
86 WaitForDatabaseThread(); 89 WaitForDatabaseThread();
87 90
88 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 91 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
89 MessageLoop::current()->Run(); 92 MessageLoop::current()->Run();
90 db_thread_.Stop(); 93 db_thread_.Stop();
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 EXPECT_EQ(handle2, profile_consumer2.handle()); 542 EXPECT_EQ(handle2, profile_consumer2.handle());
540 ASSERT_EQ(0U, profile_consumer2.result().size()); 543 ASSERT_EQ(0U, profile_consumer2.result().size());
541 544
542 // Check that the credit card was removed. 545 // Check that the credit card was removed.
543 AutofillWebDataServiceConsumer<std::vector<CreditCard*> > card_consumer2; 546 AutofillWebDataServiceConsumer<std::vector<CreditCard*> > card_consumer2;
544 handle2 = wds_->GetCreditCards(&card_consumer2); 547 handle2 = wds_->GetCreditCards(&card_consumer2);
545 MessageLoop::current()->Run(); 548 MessageLoop::current()->Run();
546 EXPECT_EQ(handle2, card_consumer2.handle()); 549 EXPECT_EQ(handle2, card_consumer2.handle());
547 ASSERT_EQ(0U, card_consumer2.result().size()); 550 ASSERT_EQ(0U, card_consumer2.result().size());
548 } 551 }
OLDNEW
« no previous file with comments | « chrome/browser/webdata/web_data_service_factory.cc ('k') | chrome/browser/webdata/web_database_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698