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

Side by Side Diff: chrome/browser/browsing_data/browsing_data_quota_helper_unittest.cc

Issue 11413050: chrome/browser: Update calls from RunAllPending() to RunUntilIdle(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 helper_ = new BrowsingDataQuotaHelperImpl( 42 helper_ = new BrowsingDataQuotaHelperImpl(
43 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), 43 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
44 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), 44 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
45 quota_manager_); 45 quota_manager_);
46 } 46 }
47 47
48 virtual void TearDown() OVERRIDE { 48 virtual void TearDown() OVERRIDE {
49 helper_ = NULL; 49 helper_ = NULL;
50 quota_manager_ = NULL; 50 quota_manager_ = NULL;
51 quota_info_.clear(); 51 quota_info_.clear();
52 MessageLoop::current()->RunAllPending(); 52 MessageLoop::current()->RunUntilIdle();
53 } 53 }
54 54
55 protected: 55 protected:
56 const QuotaInfoArray& quota_info() const { 56 const QuotaInfoArray& quota_info() const {
57 return quota_info_; 57 return quota_info_;
58 } 58 }
59 59
60 bool fetching_completed() const { 60 bool fetching_completed() const {
61 return fetching_completed_; 61 return fetching_completed_;
62 } 62 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 bool fetching_completed_; 125 bool fetching_completed_;
126 QuotaInfoArray quota_info_; 126 QuotaInfoArray quota_info_;
127 int64 quota_; 127 int64 quota_;
128 base::WeakPtrFactory<BrowsingDataQuotaHelperTest> weak_factory_; 128 base::WeakPtrFactory<BrowsingDataQuotaHelperTest> weak_factory_;
129 129
130 DISALLOW_COPY_AND_ASSIGN(BrowsingDataQuotaHelperTest); 130 DISALLOW_COPY_AND_ASSIGN(BrowsingDataQuotaHelperTest);
131 }; 131 };
132 132
133 TEST_F(BrowsingDataQuotaHelperTest, Empty) { 133 TEST_F(BrowsingDataQuotaHelperTest, Empty) {
134 StartFetching(); 134 StartFetching();
135 MessageLoop::current()->RunAllPending(); 135 MessageLoop::current()->RunUntilIdle();
136 EXPECT_TRUE(fetching_completed()); 136 EXPECT_TRUE(fetching_completed());
137 EXPECT_TRUE(quota_info().empty()); 137 EXPECT_TRUE(quota_info().empty());
138 } 138 }
139 139
140 TEST_F(BrowsingDataQuotaHelperTest, FetchData) { 140 TEST_F(BrowsingDataQuotaHelperTest, FetchData) {
141 const quota::MockOriginData kOrigins[] = { 141 const quota::MockOriginData kOrigins[] = {
142 {"http://example.com/", quota::kStorageTypeTemporary, 1}, 142 {"http://example.com/", quota::kStorageTypeTemporary, 1},
143 {"https://example.com/", quota::kStorageTypeTemporary, 10}, 143 {"https://example.com/", quota::kStorageTypeTemporary, 10},
144 {"http://example.com/", quota::kStorageTypePersistent, 100}, 144 {"http://example.com/", quota::kStorageTypePersistent, 100},
145 {"http://example2.com/", quota::kStorageTypeTemporary, 1000}, 145 {"http://example2.com/", quota::kStorageTypeTemporary, 1000},
146 }; 146 };
147 147
148 RegisterClient(kOrigins, arraysize(kOrigins)); 148 RegisterClient(kOrigins, arraysize(kOrigins));
149 StartFetching(); 149 StartFetching();
150 MessageLoop::current()->RunAllPending(); 150 MessageLoop::current()->RunUntilIdle();
151 EXPECT_TRUE(fetching_completed()); 151 EXPECT_TRUE(fetching_completed());
152 152
153 std::set<QuotaInfo> expected, actual; 153 std::set<QuotaInfo> expected, actual;
154 actual.insert(quota_info().begin(), quota_info().end()); 154 actual.insert(quota_info().begin(), quota_info().end());
155 expected.insert(QuotaInfo("example.com", 11, 100)); 155 expected.insert(QuotaInfo("example.com", 11, 100));
156 expected.insert(QuotaInfo("example2.com", 1000, 0)); 156 expected.insert(QuotaInfo("example2.com", 1000, 0));
157 EXPECT_TRUE(expected == actual); 157 EXPECT_TRUE(expected == actual);
158 } 158 }
159 159
160 TEST_F(BrowsingDataQuotaHelperTest, IgnoreExtensionsAndDevTools) { 160 TEST_F(BrowsingDataQuotaHelperTest, IgnoreExtensionsAndDevTools) {
161 const quota::MockOriginData kOrigins[] = { 161 const quota::MockOriginData kOrigins[] = {
162 {"http://example.com/", quota::kStorageTypeTemporary, 1}, 162 {"http://example.com/", quota::kStorageTypeTemporary, 1},
163 {"https://example.com/", quota::kStorageTypeTemporary, 10}, 163 {"https://example.com/", quota::kStorageTypeTemporary, 10},
164 {"http://example.com/", quota::kStorageTypePersistent, 100}, 164 {"http://example.com/", quota::kStorageTypePersistent, 100},
165 {"http://example2.com/", quota::kStorageTypeTemporary, 1000}, 165 {"http://example2.com/", quota::kStorageTypeTemporary, 1000},
166 {"chrome-extension://abcdefghijklmnopqrstuvwxyz/", 166 {"chrome-extension://abcdefghijklmnopqrstuvwxyz/",
167 quota::kStorageTypeTemporary, 10000}, 167 quota::kStorageTypeTemporary, 10000},
168 {"chrome-extension://abcdefghijklmnopqrstuvwxyz/", 168 {"chrome-extension://abcdefghijklmnopqrstuvwxyz/",
169 quota::kStorageTypePersistent, 100000}, 169 quota::kStorageTypePersistent, 100000},
170 {"chrome-devtools://abcdefghijklmnopqrstuvwxyz/", 170 {"chrome-devtools://abcdefghijklmnopqrstuvwxyz/",
171 quota::kStorageTypeTemporary, 10000}, 171 quota::kStorageTypeTemporary, 10000},
172 {"chrome-devtools://abcdefghijklmnopqrstuvwxyz/", 172 {"chrome-devtools://abcdefghijklmnopqrstuvwxyz/",
173 quota::kStorageTypePersistent, 100000}, 173 quota::kStorageTypePersistent, 100000},
174 }; 174 };
175 175
176 RegisterClient(kOrigins, arraysize(kOrigins)); 176 RegisterClient(kOrigins, arraysize(kOrigins));
177 StartFetching(); 177 StartFetching();
178 MessageLoop::current()->RunAllPending(); 178 MessageLoop::current()->RunUntilIdle();
179 EXPECT_TRUE(fetching_completed()); 179 EXPECT_TRUE(fetching_completed());
180 180
181 std::set<QuotaInfo> expected, actual; 181 std::set<QuotaInfo> expected, actual;
182 actual.insert(quota_info().begin(), quota_info().end()); 182 actual.insert(quota_info().begin(), quota_info().end());
183 expected.insert(QuotaInfo("example.com", 11, 100)); 183 expected.insert(QuotaInfo("example.com", 11, 100));
184 expected.insert(QuotaInfo("example2.com", 1000, 0)); 184 expected.insert(QuotaInfo("example2.com", 1000, 0));
185 EXPECT_TRUE(expected == actual); 185 EXPECT_TRUE(expected == actual);
186 } 186 }
187 187
188 TEST_F(BrowsingDataQuotaHelperTest, RevokeHostQuota) { 188 TEST_F(BrowsingDataQuotaHelperTest, RevokeHostQuota) {
189 const std::string kHost1("example1.com"); 189 const std::string kHost1("example1.com");
190 const std::string kHost2("example2.com"); 190 const std::string kHost2("example2.com");
191 191
192 SetPersistentHostQuota(kHost1, 1); 192 SetPersistentHostQuota(kHost1, 1);
193 SetPersistentHostQuota(kHost2, 10); 193 SetPersistentHostQuota(kHost2, 10);
194 MessageLoop::current()->RunAllPending(); 194 MessageLoop::current()->RunUntilIdle();
195 195
196 RevokeHostQuota(kHost1); 196 RevokeHostQuota(kHost1);
197 MessageLoop::current()->RunAllPending(); 197 MessageLoop::current()->RunUntilIdle();
198 198
199 GetPersistentHostQuota(kHost1); 199 GetPersistentHostQuota(kHost1);
200 MessageLoop::current()->RunAllPending(); 200 MessageLoop::current()->RunUntilIdle();
201 EXPECT_EQ(0, quota()); 201 EXPECT_EQ(0, quota());
202 202
203 GetPersistentHostQuota(kHost2); 203 GetPersistentHostQuota(kHost2);
204 MessageLoop::current()->RunAllPending(); 204 MessageLoop::current()->RunUntilIdle();
205 EXPECT_EQ(10, quota()); 205 EXPECT_EQ(10, quota());
206 } 206 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698