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/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 "chrome/test/base/testing_profile.h" | 8 #include "chrome/test/base/testing_profile.h" |
9 #include "chrome/test/base/testing_browser_process.h" | 9 #include "chrome/test/base/testing_browser_process.h" |
10 #include "content/browser/tab_contents/tab_contents.h" | 10 #include "content/browser/tab_contents/tab_contents.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 virtual void CloseContents(TabContents* source) {} | 56 virtual void CloseContents(TabContents* source) {} |
57 | 57 |
58 virtual void MoveContents(TabContents* source, const gfx::Rect& pos) {} | 58 virtual void MoveContents(TabContents* source, const gfx::Rect& pos) {} |
59 | 59 |
60 virtual void UpdateTargetURL(TabContents* source, const GURL& url) {} | 60 virtual void UpdateTargetURL(TabContents* source, const GURL& url) {} |
61 }; | 61 }; |
62 | 62 |
63 TEST(TabContentsDelegateTest, UnregisterInDestructor) { | 63 TEST(TabContentsDelegateTest, UnregisterInDestructor) { |
64 MessageLoop loop(MessageLoop::TYPE_UI); | 64 MessageLoop loop(MessageLoop::TYPE_UI); |
65 ScopedTestingBrowserProcess browser_process; | |
66 scoped_ptr<MockTabContentsDelegate> delegate(new MockTabContentsDelegate()); | 65 scoped_ptr<MockTabContentsDelegate> delegate(new MockTabContentsDelegate()); |
67 scoped_ptr<Profile> profile(new TestingProfile()); | 66 scoped_ptr<Profile> profile(new TestingProfile()); |
68 scoped_ptr<TabContents> contents_a( | 67 scoped_ptr<TabContents> contents_a( |
69 new TabContents(profile.get(), NULL, 0, NULL, NULL)); | 68 new TabContents(profile.get(), NULL, 0, NULL, NULL)); |
70 scoped_ptr<TabContents> contents_b( | 69 scoped_ptr<TabContents> contents_b( |
71 new TabContents(profile.get(), NULL, 0, NULL, NULL)); | 70 new TabContents(profile.get(), NULL, 0, NULL, NULL)); |
72 EXPECT_TRUE(contents_a->delegate() == NULL); | 71 EXPECT_TRUE(contents_a->delegate() == NULL); |
73 EXPECT_TRUE(contents_b->delegate() == NULL); | 72 EXPECT_TRUE(contents_b->delegate() == NULL); |
74 | 73 |
75 // Setting a delegate should work correctly. | 74 // Setting a delegate should work correctly. |
(...skipping 25 matching lines...) Expand all Loading... |
101 EXPECT_TRUE(contents_a->delegate() == NULL); | 100 EXPECT_TRUE(contents_a->delegate() == NULL); |
102 EXPECT_TRUE(contents_b->delegate() == NULL); | 101 EXPECT_TRUE(contents_b->delegate() == NULL); |
103 | 102 |
104 // Destroy the tab contents and run the message loop to prevent leaks. | 103 // Destroy the tab contents and run the message loop to prevent leaks. |
105 contents_a.reset(NULL); | 104 contents_a.reset(NULL); |
106 contents_b.reset(NULL); | 105 contents_b.reset(NULL); |
107 loop.RunAllPending(); | 106 loop.RunAllPending(); |
108 } | 107 } |
109 | 108 |
110 } // namespace | 109 } // namespace |
OLD | NEW |