| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "content/browser/shared_worker/shared_worker_instance.h" |
| 6 |
| 7 #include <memory> |
| 8 |
| 5 #include "base/macros.h" | 9 #include "base/macros.h" |
| 6 #include "base/memory/scoped_ptr.h" | |
| 7 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 9 #include "content/browser/shared_worker/shared_worker_instance.h" | |
| 10 #include "content/browser/shared_worker/worker_storage_partition.h" | 12 #include "content/browser/shared_worker/worker_storage_partition.h" |
| 11 #include "content/public/test/test_browser_context.h" | 13 #include "content/public/test/test_browser_context.h" |
| 12 #include "content/public/test/test_browser_thread_bundle.h" | 14 #include "content/public/test/test_browser_thread_bundle.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 16 |
| 15 namespace content { | 17 namespace content { |
| 16 | 18 |
| 17 class SharedWorkerInstanceTest : public testing::Test { | 19 class SharedWorkerInstanceTest : public testing::Test { |
| 18 protected: | 20 protected: |
| 19 SharedWorkerInstanceTest() | 21 SharedWorkerInstanceTest() |
| (...skipping 12 matching lines...) Expand all Loading... |
| 32 bool Matches(const SharedWorkerInstance& instance, | 34 bool Matches(const SharedWorkerInstance& instance, |
| 33 const std::string& url, | 35 const std::string& url, |
| 34 const base::StringPiece& name) { | 36 const base::StringPiece& name) { |
| 35 return instance.Matches(GURL(url), | 37 return instance.Matches(GURL(url), |
| 36 base::ASCIIToUTF16(name), | 38 base::ASCIIToUTF16(name), |
| 37 partition_id_, | 39 partition_id_, |
| 38 browser_context_->GetResourceContext()); | 40 browser_context_->GetResourceContext()); |
| 39 } | 41 } |
| 40 | 42 |
| 41 TestBrowserThreadBundle thread_bundle_; | 43 TestBrowserThreadBundle thread_bundle_; |
| 42 scoped_ptr<TestBrowserContext> browser_context_; | 44 std::unique_ptr<TestBrowserContext> browser_context_; |
| 43 scoped_ptr<WorkerStoragePartition> partition_; | 45 std::unique_ptr<WorkerStoragePartition> partition_; |
| 44 const WorkerStoragePartitionId partition_id_; | 46 const WorkerStoragePartitionId partition_id_; |
| 45 | 47 |
| 46 DISALLOW_COPY_AND_ASSIGN(SharedWorkerInstanceTest); | 48 DISALLOW_COPY_AND_ASSIGN(SharedWorkerInstanceTest); |
| 47 }; | 49 }; |
| 48 | 50 |
| 49 TEST_F(SharedWorkerInstanceTest, MatchesTest) { | 51 TEST_F(SharedWorkerInstanceTest, MatchesTest) { |
| 50 SharedWorkerInstance instance1( | 52 SharedWorkerInstance instance1( |
| 51 GURL("http://example.com/w.js"), base::string16(), base::string16(), | 53 GURL("http://example.com/w.js"), base::string16(), base::string16(), |
| 52 blink::WebContentSecurityPolicyTypeReport, blink::WebAddressSpacePublic, | 54 blink::WebContentSecurityPolicyTypeReport, blink::WebAddressSpacePublic, |
| 53 browser_context_->GetResourceContext(), partition_id_, | 55 browser_context_->GetResourceContext(), partition_id_, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 base::string16(), blink::WebContentSecurityPolicyTypeReport, | 89 base::string16(), blink::WebContentSecurityPolicyTypeReport, |
| 88 static_cast<blink::WebAddressSpace>(i), | 90 static_cast<blink::WebAddressSpace>(i), |
| 89 browser_context_->GetResourceContext(), partition_id_, | 91 browser_context_->GetResourceContext(), partition_id_, |
| 90 blink::WebSharedWorkerCreationContextTypeNonsecure); | 92 blink::WebSharedWorkerCreationContextTypeNonsecure); |
| 91 EXPECT_EQ(static_cast<blink::WebAddressSpace>(i), | 93 EXPECT_EQ(static_cast<blink::WebAddressSpace>(i), |
| 92 instance.creation_address_space()); | 94 instance.creation_address_space()); |
| 93 } | 95 } |
| 94 } | 96 } |
| 95 | 97 |
| 96 } // namespace content | 98 } // namespace content |
| OLD | NEW |