| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "content/browser/web_contents/web_contents_impl.h" | 8 #include "content/browser/web_contents/web_contents_impl.h" |
| 9 #include "content/browser/renderer_host/test_render_view_host.h" | 9 #include "content/browser/renderer_host/test_render_view_host.h" |
| 10 #include "content/public/browser/browser_thread.h" | |
| 11 #include "content/public/browser/web_contents_delegate.h" | 10 #include "content/public/browser/web_contents_delegate.h" |
| 12 #include "content/public/test/test_browser_context.h" | 11 #include "content/public/test/test_browser_context.h" |
| 13 #include "content/public/test/test_browser_thread.h" | |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 13 |
| 16 namespace content { | 14 namespace content { |
| 17 | 15 |
| 18 class MockWebContentsDelegate : public WebContentsDelegate { | 16 class MockWebContentsDelegate : public WebContentsDelegate { |
| 19 public: | |
| 20 virtual ~MockWebContentsDelegate() {} | |
| 21 }; | 17 }; |
| 22 | 18 |
| 23 class WebContentsDelegateTest : public RenderViewHostImplTestHarness { | 19 class WebContentsDelegateTest : public RenderViewHostImplTestHarness { |
| 24 public: | |
| 25 WebContentsDelegateTest() | |
| 26 : file_user_blocking_thread_( | |
| 27 BrowserThread::FILE_USER_BLOCKING, &message_loop_), | |
| 28 io_thread_(BrowserThread::IO, &message_loop_) { | |
| 29 } | |
| 30 | |
| 31 private: | |
| 32 TestBrowserThread file_user_blocking_thread_; | |
| 33 TestBrowserThread io_thread_; | |
| 34 }; | 20 }; |
| 35 | 21 |
| 36 TEST_F(WebContentsDelegateTest, UnregisterInDestructor) { | 22 TEST_F(WebContentsDelegateTest, UnregisterInDestructor) { |
| 37 scoped_ptr<WebContentsImpl> contents_a(static_cast<WebContentsImpl*>( | 23 scoped_ptr<WebContentsImpl> contents_a(static_cast<WebContentsImpl*>( |
| 38 WebContents::Create(WebContents::CreateParams(browser_context_.get())))); | 24 WebContents::Create(WebContents::CreateParams(browser_context_.get())))); |
| 39 scoped_ptr<WebContentsImpl> contents_b(static_cast<WebContentsImpl*>( | 25 scoped_ptr<WebContentsImpl> contents_b(static_cast<WebContentsImpl*>( |
| 40 WebContents::Create(WebContents::CreateParams(browser_context_.get())))); | 26 WebContents::Create(WebContents::CreateParams(browser_context_.get())))); |
| 41 EXPECT_EQ(NULL, contents_a->GetDelegate()); | 27 EXPECT_EQ(NULL, contents_a->GetDelegate()); |
| 42 EXPECT_EQ(NULL, contents_b->GetDelegate()); | 28 EXPECT_EQ(NULL, contents_b->GetDelegate()); |
| 43 | 29 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 71 delegate.reset(NULL); | 57 delegate.reset(NULL); |
| 72 EXPECT_TRUE(contents_a->GetDelegate() == NULL); | 58 EXPECT_TRUE(contents_a->GetDelegate() == NULL); |
| 73 EXPECT_TRUE(contents_b->GetDelegate() == NULL); | 59 EXPECT_TRUE(contents_b->GetDelegate() == NULL); |
| 74 | 60 |
| 75 // Destroy the WebContentses and run the message loop to prevent leaks. | 61 // Destroy the WebContentses and run the message loop to prevent leaks. |
| 76 contents_a.reset(); | 62 contents_a.reset(); |
| 77 contents_b.reset(); | 63 contents_b.reset(); |
| 78 } | 64 } |
| 79 | 65 |
| 80 } // namespace content | 66 } // namespace content |
| OLD | NEW |