Index: content/browser/service_worker/service_worker_quota_client_unittest.cc |
diff --git a/content/browser/service_worker/service_worker_quota_client_unittest.cc b/content/browser/service_worker/service_worker_quota_client_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..6fcb0bd7fbeaa4dd944e2ecc2045c85e57a97488 |
--- /dev/null |
+++ b/content/browser/service_worker/service_worker_quota_client_unittest.cc |
@@ -0,0 +1,56 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "content/browser/service_worker/service_worker_quota_client.h" |
+ |
+#include "base/bind.h" |
+#include "base/memory/ref_counted.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "content/browser/service_worker/service_worker_context_wrapper.h" |
+#include "testing/gmock/include/gmock/gmock.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+#include "url/gurl.h" |
+ |
+namespace content { |
+ |
+class MockServiceWorkerContextWrapper : public ServiceWorkerContextWrapper { |
+ public: |
+ MockServiceWorkerContextWrapper() : ServiceWorkerContextWrapper(nullptr) {} |
+ |
+ MOCK_CONST_METHOD0(IsAlive, bool()); |
+ MOCK_METHOD1(GetAllOriginsInfo, |
+ void(const ServiceWorkerContext::GetUsageInfoCallback&)); |
+ |
+ protected: |
+ friend class ServiceWorkerQuotaClientTest; |
+ |
+ virtual ~MockServiceWorkerContextWrapper() override {} |
+}; |
+ |
+void GetAllOriginsForTypeCallback(const std::set<GURL>& origins) { |
+} |
+ |
+class ServiceWorkerQuotaClientTest : public testing::Test { |
+ public: |
+ virtual ~ServiceWorkerQuotaClientTest() override {} |
+ ServiceWorkerQuotaClientTest() {} |
+ |
+ virtual void SetUp() override { |
+ wrapper_ = new MockServiceWorkerContextWrapper(); |
+ client_.reset(new ServiceWorkerQuotaClient(wrapper_.get())); |
+ } |
+ |
+ scoped_refptr<MockServiceWorkerContextWrapper> wrapper_; |
+ scoped_ptr<ServiceWorkerQuotaClient> client_; |
+}; |
+ |
+TEST_F(ServiceWorkerQuotaClientTest, TestNoopOnDead) { |
+ EXPECT_CALL(*wrapper_, IsAlive()).WillOnce(testing::Return(false)); |
+ EXPECT_CALL(*wrapper_, GetAllOriginsInfo(testing::_)).Times(0); |
+ |
+ client_->GetOriginsForType(storage::StorageType::kStorageTypeTemporary, |
+ base::Bind(&GetAllOriginsForTypeCallback)); |
+} |
+ |
+} // namespace content |