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

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

Issue 7550053: Cleanup of code in WebDataService unittests (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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/file_util.h"
10 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/scoped_vector.h" 11 #include "base/memory/scoped_vector.h"
13 #include "base/message_loop.h" 12 #include "base/message_loop.h"
14 #include "base/path_service.h" 13 #include "base/scoped_temp_dir.h"
15 #include "base/stl_util.h" 14 #include "base/stl_util.h"
16 #include "base/string16.h" 15 #include "base/string16.h"
17 #include "base/string_util.h" 16 #include "base/string_util.h"
18 #include "base/synchronization/waitable_event.h" 17 #include "base/synchronization/waitable_event.h"
19 #include "base/time.h" 18 #include "base/time.h"
20 #include "base/utf_string_conversions.h" 19 #include "base/utf_string_conversions.h"
21 #include "chrome/browser/autofill/autofill_profile.h" 20 #include "chrome/browser/autofill/autofill_profile.h"
22 #include "chrome/browser/autofill/credit_card.h" 21 #include "chrome/browser/autofill/credit_card.h"
23 #include "chrome/browser/webdata/autofill_change.h" 22 #include "chrome/browser/webdata/autofill_change.h"
24 #include "chrome/browser/webdata/autofill_entry.h" 23 #include "chrome/browser/webdata/autofill_entry.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 class WebDataServiceTest : public testing::Test { 70 class WebDataServiceTest : public testing::Test {
72 public: 71 public:
73 WebDataServiceTest() 72 WebDataServiceTest()
74 : ui_thread_(BrowserThread::UI, &message_loop_), 73 : ui_thread_(BrowserThread::UI, &message_loop_),
75 db_thread_(BrowserThread::DB) {} 74 db_thread_(BrowserThread::DB) {}
76 75
77 protected: 76 protected:
78 virtual void SetUp() { 77 virtual void SetUp() {
79 db_thread_.Start(); 78 db_thread_.Start();
80 79
81 PathService::Get(chrome::DIR_TEST_DATA, &profile_dir_); 80 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
82 const std::string test_profile = "WebDataServiceTest";
83 profile_dir_ = profile_dir_.AppendASCII(test_profile);
84 file_util::Delete(profile_dir_, true);
85 file_util::CreateDirectory(profile_dir_);
86 wds_ = new WebDataService(); 81 wds_ = new WebDataService();
87 wds_->Init(profile_dir_); 82 wds_->Init(temp_dir_.path());
88 } 83 }
89 84
90 virtual void TearDown() { 85 virtual void TearDown() {
91 if (wds_.get()) 86 if (wds_.get())
92 wds_->Shutdown(); 87 wds_->Shutdown();
93 file_util::Delete(profile_dir_, true);
94 88
95 db_thread_.Stop(); 89 db_thread_.Stop();
96 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask); 90 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask);
97 MessageLoop::current()->Run(); 91 MessageLoop::current()->Run();
98 } 92 }
99 93
100 MessageLoopForUI message_loop_; 94 MessageLoopForUI message_loop_;
101 BrowserThread ui_thread_; 95 BrowserThread ui_thread_;
102 BrowserThread db_thread_; 96 BrowserThread db_thread_;
103 FilePath profile_dir_; 97 FilePath profile_dir_;
104 scoped_refptr<WebDataService> wds_; 98 scoped_refptr<WebDataService> wds_;
99 ScopedTempDir temp_dir_;
105 }; 100 };
106 101
107 class WebDataServiceAutofillTest : public WebDataServiceTest { 102 class WebDataServiceAutofillTest : public WebDataServiceTest {
108 public: 103 public:
109 WebDataServiceAutofillTest() 104 WebDataServiceAutofillTest()
110 : WebDataServiceTest(), 105 : WebDataServiceTest(),
111 unique_id1_(1), 106 unique_id1_(1),
112 unique_id2_(2), 107 unique_id2_(2),
113 test_timeout_(TimeDelta::FromSeconds(kWebDataServiceTimeoutSeconds)), 108 test_timeout_(TimeDelta::FromSeconds(kWebDataServiceTimeoutSeconds)),
114 done_event_(false, false) {} 109 done_event_(false, false) {}
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 wds_->GetWebIntents(ASCIIToUTF16("share"), &consumer); 633 wds_->GetWebIntents(ASCIIToUTF16("share"), &consumer);
639 WebIntentsConsumer::WaitUntilCalled(); 634 WebIntentsConsumer::WaitUntilCalled();
640 ASSERT_EQ(1U, consumer.intents.size()); 635 ASSERT_EQ(1U, consumer.intents.size());
641 636
642 intent.type = ASCIIToUTF16("video/*"); 637 intent.type = ASCIIToUTF16("video/*");
643 EXPECT_EQ(intent.service_url, consumer.intents[0].service_url); 638 EXPECT_EQ(intent.service_url, consumer.intents[0].service_url);
644 EXPECT_EQ(intent.action, consumer.intents[0].action); 639 EXPECT_EQ(intent.action, consumer.intents[0].action);
645 EXPECT_EQ(intent.type, consumer.intents[0].type); 640 EXPECT_EQ(intent.type, consumer.intents[0].type);
646 } 641 }
647 642
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698