| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
| 7 #include "chrome/test/testing_profile.h" | 7 #include "chrome/test/testing_profile.h" |
| 8 #include "content/browser/tab_contents/tab_contents.h" | 8 #include "content/browser/tab_contents/tab_contents.h" |
| 9 #include "content/browser/tab_contents/tab_contents_delegate.h" | 9 #include "content/browser/tab_contents/tab_contents_delegate.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 virtual void CloseContents(TabContents* source) {} | 47 virtual void CloseContents(TabContents* source) {} |
| 48 | 48 |
| 49 virtual void MoveContents(TabContents* source, const gfx::Rect& pos) {} | 49 virtual void MoveContents(TabContents* source, const gfx::Rect& pos) {} |
| 50 | 50 |
| 51 virtual void UpdateTargetURL(TabContents* source, const GURL& url) {} | 51 virtual void UpdateTargetURL(TabContents* source, const GURL& url) {} |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 TEST(TabContentsDelegateTest, UnregisterInDestructor) { | 54 TEST(TabContentsDelegateTest, UnregisterInDestructor) { |
| 55 MessageLoop loop(MessageLoop::TYPE_UI); | 55 MessageLoop loop(MessageLoop::TYPE_UI); |
| 56 BrowserThread ui_thread(BrowserThread::UI, &loop); |
| 56 scoped_ptr<MockTabContentsDelegate> delegate(new MockTabContentsDelegate()); | 57 scoped_ptr<MockTabContentsDelegate> delegate(new MockTabContentsDelegate()); |
| 57 scoped_ptr<Profile> profile(new TestingProfile()); | 58 scoped_ptr<Profile> profile(new TestingProfile()); |
| 58 scoped_ptr<TabContents> contents_a( | 59 scoped_ptr<TabContents> contents_a( |
| 59 new TabContents(profile.get(), NULL, 0, NULL, NULL)); | 60 new TabContents(profile.get(), NULL, 0, NULL, NULL)); |
| 60 scoped_ptr<TabContents> contents_b( | 61 scoped_ptr<TabContents> contents_b( |
| 61 new TabContents(profile.get(), NULL, 0, NULL, NULL)); | 62 new TabContents(profile.get(), NULL, 0, NULL, NULL)); |
| 62 EXPECT_TRUE(contents_a->delegate() == NULL); | 63 EXPECT_TRUE(contents_a->delegate() == NULL); |
| 63 EXPECT_TRUE(contents_b->delegate() == NULL); | 64 EXPECT_TRUE(contents_b->delegate() == NULL); |
| 64 | 65 |
| 65 // Setting a delegate should work correctly. | 66 // Setting a delegate should work correctly. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 91 EXPECT_TRUE(contents_a->delegate() == NULL); | 92 EXPECT_TRUE(contents_a->delegate() == NULL); |
| 92 EXPECT_TRUE(contents_b->delegate() == NULL); | 93 EXPECT_TRUE(contents_b->delegate() == NULL); |
| 93 | 94 |
| 94 // Destroy the tab contents and run the message loop to prevent leaks. | 95 // Destroy the tab contents and run the message loop to prevent leaks. |
| 95 contents_a.reset(NULL); | 96 contents_a.reset(NULL); |
| 96 contents_b.reset(NULL); | 97 contents_b.reset(NULL); |
| 97 loop.RunAllPending(); | 98 loop.RunAllPending(); |
| 98 } | 99 } |
| 99 | 100 |
| 100 } // namespace | 101 } // namespace |
| OLD | NEW |