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

Side by Side Diff: content/browser/service_worker/service_worker_quota_client_unittest.cc

Issue 633273002: Added quota client for serviceworker. Enables 'clear past <time> data'. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix for crashing, added IsAlive on wrapper Created 6 years, 2 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
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/browser/service_worker/service_worker_quota_client.h"
6
7 #include "base/bind.h"
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "content/browser/service_worker/service_worker_context_wrapper.h"
11 #include "testing/gmock/include/gmock/gmock.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "url/gurl.h"
14
15 namespace content {
16
17 class MockServiceWorkerContextWrapper : public ServiceWorkerContextWrapper {
18 public:
19 MockServiceWorkerContextWrapper() : ServiceWorkerContextWrapper(nullptr) {}
20
21 MOCK_CONST_METHOD0(IsAlive, bool());
22 MOCK_METHOD1(GetAllOriginsInfo,
23 void(const ServiceWorkerContext::GetUsageInfoCallback&));
24
25 protected:
26 friend class ServiceWorkerQuotaClientTest;
27
28 virtual ~MockServiceWorkerContextWrapper() override {}
29 };
30
31 void GetAllOriginsForTypeCallback(const std::set<GURL>& origins) {
32 }
33
34 class ServiceWorkerQuotaClientTest : public testing::Test {
35 public:
36 virtual ~ServiceWorkerQuotaClientTest() override {}
37 ServiceWorkerQuotaClientTest() {}
38
39 virtual void SetUp() override {
40 wrapper_ = new MockServiceWorkerContextWrapper();
41 client_.reset(new ServiceWorkerQuotaClient(wrapper_.get()));
42 }
43
44 scoped_refptr<MockServiceWorkerContextWrapper> wrapper_;
45 scoped_ptr<ServiceWorkerQuotaClient> client_;
46 };
47
48 TEST_F(ServiceWorkerQuotaClientTest, TestNoopOnDead) {
49 EXPECT_CALL(*wrapper_, IsAlive()).WillOnce(testing::Return(false));
50 EXPECT_CALL(*wrapper_, GetAllOriginsInfo(testing::_)).Times(0);
51
52 client_->GetOriginsForType(storage::StorageType::kStorageTypeTemporary,
53 base::Bind(&GetAllOriginsForTypeCallback));
54 }
55
56 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698