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

Side by Side Diff: extensions/browser/quota_service_unittest.cc

Issue 704453002: Allow extension function call quota to be un-throttled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: betterify Created 6 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/message_loop/message_loop.h" 5 #include "base/message_loop/message_loop.h"
6 #include "base/process/process.h" 6 #include "base/process/process.h"
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "content/public/test/test_browser_thread.h" 9 #include "content/public/test/test_browser_thread.h"
10 #include "extensions/browser/extension_function.h" 10 #include "extensions/browser/extension_function.h"
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 f.get(), 280 f.get(),
281 &args_f, 281 &args_f,
282 kStartTime + TimeDelta::FromSeconds(15))); 282 kStartTime + TimeDelta::FromSeconds(15)));
283 EXPECT_NE("", 283 EXPECT_NE("",
284 service_->Assess(extension_a_, 284 service_->Assess(extension_a_,
285 g.get(), 285 g.get(),
286 &args_g, 286 &args_g,
287 kStartTime + TimeDelta::FromSeconds(15))); 287 kStartTime + TimeDelta::FromSeconds(15)));
288 } 288 }
289 289
290 TEST_F(QuotaServiceTest, ViolatorsWillBeViolators) { 290 TEST_F(QuotaServiceTest, ViolatorsWillBeForgiven) {
291 scoped_refptr<MockFunction> f(new TimedLimitMockFunction("foo")); 291 scoped_refptr<MockFunction> f(new TimedLimitMockFunction("foo"));
292 scoped_refptr<MockFunction> g(new TimedLimitMockFunction("bar"));
293 base::ListValue arg; 292 base::ListValue arg;
294 arg.Append(new base::FundamentalValue(1)); 293 arg.Append(new base::FundamentalValue(1));
295 EXPECT_EQ("", service_->Assess(extension_a_, f.get(), &arg, kStartTime)); 294 EXPECT_EQ("", service_->Assess(extension_a_, f.get(), &arg, kStartTime));
296 EXPECT_EQ("", 295 EXPECT_EQ("",
297 service_->Assess(extension_a_, 296 service_->Assess(extension_a_,
298 f.get(), 297 f.get(),
299 &arg, 298 &arg,
300 kStartTime + TimeDelta::FromSeconds(10))); 299 kStartTime + TimeDelta::FromSeconds(10)));
301 EXPECT_NE("", 300 EXPECT_NE("",
302 service_->Assess(extension_a_, 301 service_->Assess(extension_a_,
303 f.get(), 302 f.get(),
304 &arg, 303 &arg,
305 kStartTime + TimeDelta::FromSeconds(15))); 304 kStartTime + TimeDelta::FromSeconds(15)));
306 305
307 // We don't allow this extension to use quota limited functions even if they 306 // Waiting a while will give the extension access to the function again.
308 // wait a while. 307 EXPECT_EQ("", service_->Assess(extension_a_, f.get(), &arg,
309 EXPECT_NE( 308 kStartTime + TimeDelta::FromDays(1)));
310 "", 309
311 service_->Assess( 310 // And lose it again soon after.
312 extension_a_, f.get(), &arg, kStartTime + TimeDelta::FromDays(1))); 311 EXPECT_EQ("", service_->Assess(extension_a_, f.get(), &arg,
313 EXPECT_NE( 312 kStartTime + TimeDelta::FromDays(1) +
314 "", 313 TimeDelta::FromSeconds(10)));
315 service_->Assess( 314 EXPECT_NE("", service_->Assess(extension_a_, f.get(), &arg,
316 extension_a_, g.get(), &arg, kStartTime + TimeDelta::FromDays(1))); 315 kStartTime + TimeDelta::FromDays(1) +
316 TimeDelta::FromSeconds(15)));
317
318 // Going further over quota should continue to fail within this time period,
319 // but still all restored later.
320 EXPECT_NE("", service_->Assess(extension_a_, f.get(), &arg,
321 kStartTime + TimeDelta::FromDays(1) +
322 TimeDelta::FromSeconds(20)));
323 EXPECT_NE("", service_->Assess(extension_a_, f.get(), &arg,
324 kStartTime + TimeDelta::FromDays(1) +
325 TimeDelta::FromSeconds(25)));
326
327 // Like now.
328 EXPECT_EQ("", service_->Assess(extension_a_, f.get(), &arg,
329 kStartTime + TimeDelta::FromDays(2)));
317 } 330 }
318 331
319 } // namespace extensions 332 } // namespace extensions
OLDNEW
« extensions/browser/quota_service.h ('K') | « extensions/browser/quota_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698