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

Side by Side Diff: chrome/browser/search_engines/template_url_service_test_util.h

Issue 17127002: Correctly integrate StoragePartition into TestingProfile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix InstantNTP test. Created 7 years, 5 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 #ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_TEST_UTIL_H_ 5 #ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_TEST_UTIL_H_
6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_TEST_UTIL_H_ 6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_TEST_UTIL_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/files/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/strings/string16.h" 15 #include "base/strings/string16.h"
16 #include "chrome/browser/search_engines/template_url_service_observer.h" 16 #include "chrome/browser/search_engines/template_url_service_observer.h"
17 #include "chrome/test/base/testing_browser_process.h" 17 #include "chrome/test/base/testing_browser_process.h"
18 #include "content/public/test/test_browser_thread.h" 18 #include "content/public/test/test_browser_thread_bundle.h"
19 19
20 class GURL; 20 class GURL;
21 class TemplateURLService; 21 class TemplateURLService;
22 class TestingProfile; 22 class TestingProfile;
23 class TestingTemplateURLService; 23 class TestingTemplateURLService;
24 class TestingProfile; 24 class TestingProfile;
25 class WebDataService; 25 class WebDataService;
26 26
27 // TemplateURLServiceTestUtilBase contains basic API to ease testing of 27 // TemplateURLServiceTestUtilBase contains basic API to ease testing of
28 // TemplateURLService. User should take care of the infrastructure separately. 28 // TemplateURLService. User should take care of the infrastructure separately.
29 class TemplateURLServiceTestUtilBase : public TemplateURLServiceObserver { 29 class TemplateURLServiceTestUtilBase : public TemplateURLServiceObserver {
30 public: 30 public:
31 TemplateURLServiceTestUtilBase(); 31 TemplateURLServiceTestUtilBase();
32 virtual ~TemplateURLServiceTestUtilBase(); 32 virtual ~TemplateURLServiceTestUtilBase();
33 33
34 void CreateTemplateUrlService(); 34 void CreateTemplateUrlService();
35 35
36 // TemplateURLServiceObserver implemementation. 36 // TemplateURLServiceObserver implemementation.
37 virtual void OnTemplateURLServiceChanged() OVERRIDE; 37 virtual void OnTemplateURLServiceChanged() OVERRIDE;
38 38
39 // Gets the observer count. 39 // Gets the observer count.
40 int GetObserverCount(); 40 int GetObserverCount();
41 41
42 // Sets the observer count to 0. 42 // Sets the observer count to 0.
43 void ResetObserverCount(); 43 void ResetObserverCount();
44 44
45 // Blocks the caller until the service has finished servicing all pending
46 // requests.
47 static void BlockTillServiceProcessesRequests();
48
49 // Blocks the caller until the I/O thread has finished servicing all pending
50 // requests.
51 static void BlockTillIOThreadProcessesRequests();
52
53 // Makes sure the load was successful and sent the correct notification. 45 // Makes sure the load was successful and sent the correct notification.
54 void VerifyLoad(); 46 void VerifyLoad();
55 47
56 // Makes the model believe it has been loaded (without actually doing the 48 // Makes the model believe it has been loaded (without actually doing the
57 // load). Since this avoids setting the built-in keyword version, the next 49 // load). Since this avoids setting the built-in keyword version, the next
58 // load will do a merge from prepopulated data. 50 // load will do a merge from prepopulated data.
59 void ChangeModelToLoadState(); 51 void ChangeModelToLoadState();
60 52
61 // Deletes the current model (and doesn't create a new one). 53 // Deletes the current model (and doesn't create a new one).
62 void ClearModel(); 54 void ClearModel();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 // methods). 104 // methods).
113 void SetUp(); 105 void SetUp();
114 106
115 // Cleans up data structures for this class (mirroring gtest standard 107 // Cleans up data structures for this class (mirroring gtest standard
116 // methods). 108 // methods).
117 void TearDown(); 109 void TearDown();
118 110
119 // Returns the TestingProfile. 111 // Returns the TestingProfile.
120 virtual TestingProfile* profile() const OVERRIDE; 112 virtual TestingProfile* profile() const OVERRIDE;
121 113
122 // Starts an I/O thread.
123 void StartIOThread();
124
125 // Runs all pending tasks on the UI loop.
126 void PumpLoop();
127
128 private: 114 private:
129 base::MessageLoopForUI message_loop_;
130 // Needed to make the DeleteOnUIThread trait of WebDataService work 115 // Needed to make the DeleteOnUIThread trait of WebDataService work
131 // properly. 116 // properly.
132 content::TestBrowserThread ui_thread_; 117 content::TestBrowserThreadBundle thread_bundle_;
133 content::TestBrowserThread db_thread_;
134 content::TestBrowserThread io_thread_;
135 scoped_ptr<TestingProfile> profile_; 118 scoped_ptr<TestingProfile> profile_;
136 base::ScopedTempDir temp_dir_; 119 base::ScopedTempDir temp_dir_;
137 120
138 DISALLOW_COPY_AND_ASSIGN(TemplateURLServiceTestUtil); 121 DISALLOW_COPY_AND_ASSIGN(TemplateURLServiceTestUtil);
139 }; 122 };
140 123
141 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_TEST_UTIL_H_ 124 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_TEST_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698