Index: content/browser/shared_worker/shared_worker_instance_unittest.cc |
diff --git a/content/browser/frame_host/render_widget_host_view_child_frame_unittest.cc b/content/browser/shared_worker/shared_worker_instance_unittest.cc |
similarity index 10% |
copy from content/browser/frame_host/render_widget_host_view_child_frame_unittest.cc |
copy to content/browser/shared_worker/shared_worker_instance_unittest.cc |
index 95b4eb363916fbe0fd2e246bb66c701f0c09cb64..11ba2bb8cf5f6601d518d3391219f3f57957fabf 100644 |
--- a/content/browser/frame_host/render_widget_host_view_child_frame_unittest.cc |
+++ b/content/browser/shared_worker/shared_worker_instance_unittest.cc |
@@ -2,79 +2,73 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "content/browser/frame_host/render_widget_host_view_child_frame.h" |
- |
#include "base/basictypes.h" |
-#include "base/message_loop/message_loop.h" |
-#include "content/browser/renderer_host/render_widget_host_delegate.h" |
-#include "content/browser/renderer_host/render_widget_host_impl.h" |
-#include "content/common/view_messages.h" |
-#include "content/public/browser/render_widget_host_view.h" |
-#include "content/public/test/mock_render_process_host.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "content/browser/shared_worker/shared_worker_instance.h" |
+#include "content/browser/worker_host/worker_storage_partition.h" |
#include "content/public/test/test_browser_context.h" |
-#include "content/test/test_render_view_host.h" |
#include "testing/gtest/include/gtest/gtest.h" |
namespace content { |
-namespace { |
-class MockRenderWidgetHostDelegate : public RenderWidgetHostDelegate { |
- public: |
- MockRenderWidgetHostDelegate() {} |
- virtual ~MockRenderWidgetHostDelegate() {} |
-}; |
- |
-class RenderWidgetHostViewChildFrameTest : public testing::Test { |
- public: |
- RenderWidgetHostViewChildFrameTest() {} |
- virtual void SetUp() { |
- browser_context_.reset(new TestBrowserContext); |
- MockRenderProcessHost* process_host = |
- new MockRenderProcessHost(browser_context_.get()); |
- widget_host_ = new RenderWidgetHostImpl( |
- &delegate_, process_host, MSG_ROUTING_NONE, false); |
- view_ = new RenderWidgetHostViewChildFrame(widget_host_); |
+class SharedWorkerInstanceTest : public testing::Test { |
+ protected: |
+ SharedWorkerInstanceTest() |
+ : browser_context_(new TestBrowserContext()), |
+ partition_(new WorkerStoragePartition( |
+ browser_context_->GetRequestContext(), |
+ NULL, NULL, NULL, NULL, NULL, NULL)) { |
} |
- virtual void TearDown() { |
- if (view_) |
- view_->Destroy(); |
- delete widget_host_; |
- |
- browser_context_.reset(); |
- |
- message_loop_.DeleteSoon(FROM_HERE, browser_context_.release()); |
- message_loop_.RunUntilIdle(); |
+ bool Matches(const SharedWorkerInstance& instance, |
+ const wchar_t* url, |
+ const wchar_t* name) { |
kinuko
2014/02/26 14:33:25
nit: Can these just take const std::string& and co
horo
2014/02/26 16:31:22
Changed to use std::string and base::StringPiece
|
+ return instance.Matches(GURL(url), |
+ name, |
+ *partition_.get(), |
+ browser_context_->GetResourceContext()); |
} |
- protected: |
- base::MessageLoopForUI message_loop_; |
- scoped_ptr<BrowserContext> browser_context_; |
- MockRenderWidgetHostDelegate delegate_; |
- |
- // Tests should set these to NULL if they've already triggered their |
- // destruction. |
- RenderWidgetHostImpl* widget_host_; |
- RenderWidgetHostViewChildFrame* view_; |
+ scoped_ptr<TestBrowserContext> browser_context_; |
+ scoped_ptr<WorkerStoragePartition> partition_; |
- private: |
- DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewChildFrameTest); |
+ DISALLOW_COPY_AND_ASSIGN(SharedWorkerInstanceTest); |
}; |
-} // namespace |
- |
-TEST_F(RenderWidgetHostViewChildFrameTest, VisibilityTest) { |
- view_->Show(); |
- ASSERT_TRUE(view_->IsShowing()); |
- |
- view_->Hide(); |
- ASSERT_FALSE(view_->IsShowing()); |
- |
- view_->WasShown(); |
- ASSERT_TRUE(view_->IsShowing()); |
- |
- view_->WasHidden(); |
- ASSERT_FALSE(view_->IsShowing()); |
+TEST_F(SharedWorkerInstanceTest, MatchesTest) { |
+ SharedWorkerInstance instance1(GURL(L"http://example.com/w.js"), |
kinuko
2014/02/26 14:33:25
I don't think we need L"" literals for GURL (it ju
horo
2014/02/26 16:31:22
Done.
|
+ L"", |
+ L"", |
+ blink::WebContentSecurityPolicyTypeReport, |
+ browser_context_->GetResourceContext(), |
+ *partition_.get()); |
+ EXPECT_TRUE(Matches(instance1, L"http://example.com/w.js", L"")); |
+ EXPECT_FALSE(Matches(instance1, L"http://example.com/w2.js", L"")); |
+ EXPECT_FALSE(Matches(instance1, L"http://example.net/w.js", L"")); |
+ EXPECT_FALSE(Matches(instance1, L"http://example.net/w2.js", L"")); |
+ EXPECT_FALSE(Matches(instance1, L"http://example.com/w.js", L"name")); |
+ EXPECT_FALSE(Matches(instance1, L"http://example.com/w2.js", L"name")); |
+ EXPECT_FALSE(Matches(instance1, L"http://example.net/w.js", L"name")); |
+ EXPECT_FALSE(Matches(instance1, L"http://example.net/w2.js", L"name")); |
+ |
+ SharedWorkerInstance instance2(GURL(L"http://example.com/w.js"), |
+ L"name", |
+ L"", |
+ blink::WebContentSecurityPolicyTypeReport, |
+ browser_context_->GetResourceContext(), |
+ *partition_.get()); |
+ EXPECT_FALSE(Matches(instance2, L"http://example.com/w.js", L"")); |
+ EXPECT_FALSE(Matches(instance2, L"http://example.com/w2.js", L"")); |
+ EXPECT_FALSE(Matches(instance2, L"http://example.net/w.js", L"")); |
+ EXPECT_FALSE(Matches(instance2, L"http://example.net/w2.js", L"")); |
+ EXPECT_TRUE(Matches(instance2, L"http://example.com/w.js", L"name")); |
+ EXPECT_TRUE(Matches(instance2, L"http://example.com/w2.js", L"name")); |
+ EXPECT_FALSE(Matches(instance2, L"http://example.net/w.js", L"name")); |
+ EXPECT_FALSE(Matches(instance2, L"http://example.net/w2.js", L"name")); |
+ EXPECT_FALSE(Matches(instance2, L"http://example.com/w.js", L"name2")); |
+ EXPECT_FALSE(Matches(instance2, L"http://example.com/w2.js", L"name2")); |
+ EXPECT_FALSE(Matches(instance2, L"http://example.net/w.js", L"name2")); |
+ EXPECT_FALSE(Matches(instance2, L"http://example.net/w2.js", L"name2")); |
} |
} // namespace content |