| 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 15 matching lines...) Expand all Loading... |
| 26 PageTransition::Type transition) OVERRIDE { | 26 PageTransition::Type transition) OVERRIDE { |
| 27 return NULL; | 27 return NULL; |
| 28 } | 28 } |
| 29 | 29 |
| 30 virtual TabContents* OpenURLFromTab(TabContents* source, | 30 virtual TabContents* OpenURLFromTab(TabContents* source, |
| 31 const OpenURLParams& params) OVERRIDE { | 31 const OpenURLParams& params) OVERRIDE { |
| 32 return NULL; | 32 return NULL; |
| 33 } | 33 } |
| 34 | 34 |
| 35 virtual void NavigationStateChanged(const TabContents* source, | 35 virtual void NavigationStateChanged(const TabContents* source, |
| 36 unsigned changed_flags) {} | 36 unsigned changed_flags) OVERRIDE {} |
| 37 | 37 |
| 38 virtual std::string GetNavigationHeaders(const GURL& url) { | 38 virtual void AddNavigationHeaders( |
| 39 return ""; | 39 const GURL& url, std::string* headers) OVERRIDE { |
| 40 } | 40 } |
| 41 | 41 |
| 42 virtual void AddNewContents(TabContents* source, | 42 virtual void AddNewContents(TabContents* source, |
| 43 TabContents* new_contents, | 43 TabContents* new_contents, |
| 44 WindowOpenDisposition disposition, | 44 WindowOpenDisposition disposition, |
| 45 const gfx::Rect& initial_pos, | 45 const gfx::Rect& initial_pos, |
| 46 bool user_gesture) {} | 46 bool user_gesture) OVERRIDE {} |
| 47 | 47 |
| 48 virtual void ActivateContents(TabContents* contents) {} | 48 virtual void ActivateContents(TabContents* contents) OVERRIDE {} |
| 49 | 49 |
| 50 virtual void DeactivateContents(TabContents* contents) {} | 50 virtual void DeactivateContents(TabContents* contents) OVERRIDE {} |
| 51 | 51 |
| 52 virtual void LoadingStateChanged(TabContents* source) {} | 52 virtual void LoadingStateChanged(TabContents* source) OVERRIDE {} |
| 53 | 53 |
| 54 virtual void LoadProgressChanged(double progress) {} | 54 virtual void LoadProgressChanged(double progress) OVERRIDE {} |
| 55 | 55 |
| 56 virtual void CloseContents(TabContents* source) {} | 56 virtual void CloseContents(TabContents* source) OVERRIDE {} |
| 57 | 57 |
| 58 virtual void MoveContents(TabContents* source, const gfx::Rect& pos) {} | 58 virtual void MoveContents(TabContents* source, |
| 59 const gfx::Rect& pos) OVERRIDE { |
| 60 } |
| 59 | 61 |
| 60 virtual void UpdateTargetURL(TabContents* source, const GURL& url) {} | 62 virtual void UpdateTargetURL(TabContents* source, const GURL& url) OVERRIDE {} |
| 61 }; | 63 }; |
| 62 | 64 |
| 63 TEST(TabContentsDelegateTest, UnregisterInDestructor) { | 65 TEST(TabContentsDelegateTest, UnregisterInDestructor) { |
| 64 MessageLoop loop(MessageLoop::TYPE_UI); | 66 MessageLoop loop(MessageLoop::TYPE_UI); |
| 65 scoped_ptr<MockTabContentsDelegate> delegate(new MockTabContentsDelegate()); | 67 scoped_ptr<MockTabContentsDelegate> delegate(new MockTabContentsDelegate()); |
| 66 scoped_ptr<Profile> profile(new TestingProfile()); | 68 scoped_ptr<Profile> profile(new TestingProfile()); |
| 67 scoped_ptr<TabContents> contents_a( | 69 scoped_ptr<TabContents> contents_a( |
| 68 new TabContents(profile.get(), NULL, 0, NULL, NULL)); | 70 new TabContents(profile.get(), NULL, 0, NULL, NULL)); |
| 69 scoped_ptr<TabContents> contents_b( | 71 scoped_ptr<TabContents> contents_b( |
| 70 new TabContents(profile.get(), NULL, 0, NULL, NULL)); | 72 new TabContents(profile.get(), NULL, 0, NULL, NULL)); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 100 EXPECT_TRUE(contents_a->delegate() == NULL); | 102 EXPECT_TRUE(contents_a->delegate() == NULL); |
| 101 EXPECT_TRUE(contents_b->delegate() == NULL); | 103 EXPECT_TRUE(contents_b->delegate() == NULL); |
| 102 | 104 |
| 103 // Destroy the tab contents and run the message loop to prevent leaks. | 105 // Destroy the tab contents and run the message loop to prevent leaks. |
| 104 contents_a.reset(NULL); | 106 contents_a.reset(NULL); |
| 105 contents_b.reset(NULL); | 107 contents_b.reset(NULL); |
| 106 loop.RunAllPending(); | 108 loop.RunAllPending(); |
| 107 } | 109 } |
| 108 | 110 |
| 109 } // namespace | 111 } // namespace |
| OLD | NEW |