| OLD | NEW | 
|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> | 
| 6 | 6 | 
| 7 #import "chrome/browser/browser_window.h" | 7 #import "chrome/browser/browser_window.h" | 
| 8 #include "chrome/browser/cocoa/browser_test_helper.h" | 8 #include "chrome/browser/cocoa/browser_test_helper.h" | 
| 9 #import "chrome/browser/cocoa/cocoa_test_helper.h" | 9 #import "chrome/browser/cocoa/cocoa_test_helper.h" | 
| 10 #import "chrome/browser/cocoa/new_tab_button.h" | 10 #import "chrome/browser/cocoa/new_tab_button.h" | 
| 11 #import "chrome/browser/cocoa/tab_strip_controller.h" | 11 #import "chrome/browser/cocoa/tab_strip_controller.h" | 
| 12 #import "chrome/browser/cocoa/tab_strip_view.h" | 12 #import "chrome/browser/cocoa/tab_strip_view.h" | 
| 13 #include "chrome/browser/tab_contents/tab_contents.h" | 13 #include "chrome/browser/tab_contents/tab_contents.h" | 
|  | 14 #include "chrome/browser/tab_contents_wrapper.h" | 
| 14 #include "chrome/browser/renderer_host/site_instance.h" | 15 #include "chrome/browser/renderer_host/site_instance.h" | 
| 15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" | 
| 16 #include "testing/platform_test.h" | 17 #include "testing/platform_test.h" | 
| 17 | 18 | 
| 18 @interface TestTabStripControllerDelegate : | 19 @interface TestTabStripControllerDelegate : | 
| 19   NSObject<TabStripControllerDelegate> { | 20   NSObject<TabStripControllerDelegate> { | 
| 20 } | 21 } | 
| 21 @end | 22 @end | 
| 22 | 23 | 
| 23 @implementation TestTabStripControllerDelegate | 24 @implementation TestTabStripControllerDelegate | 
| 24 - (void)onSelectTabWithContents:(TabContents*)contents { | 25 - (void)onSelectTabWithContents:(TabContents*)contents { | 
| 25 } | 26 } | 
| 26 - (void)onReplaceTabWithContents:(TabContents*)contents { | 27 - (void)onReplaceTabWithContents:(TabContents*)contents { | 
| 27 } | 28 } | 
| 28 - (void)onSelectedTabChange:(TabStripModelObserver::TabChangeType)change { | 29 - (void)onSelectedTabChange:(TabStripModelObserver::TabChangeType)change { | 
| 29 } | 30 } | 
| 30 - (void)onTabDetachedWithContents:(TabContents*)contents { | 31 - (void)onTabDetachedWithContents:(TabContents*)contents { | 
| 31 } | 32 } | 
| 32 @end | 33 @end | 
| 33 | 34 | 
| 34 namespace { | 35 namespace { | 
| 35 | 36 | 
| 36 // Stub model delegate | 37 // Stub model delegate | 
| 37 class TestTabStripDelegate : public TabStripModelDelegate { | 38 class TestTabStripDelegate : public TabStripModelDelegate { | 
| 38  public: | 39  public: | 
| 39   virtual TabContents* AddBlankTab(bool foreground) { | 40   virtual TabContentsWrapper* AddBlankTab(bool foreground) { | 
| 40     return NULL; | 41     return NULL; | 
| 41   } | 42   } | 
| 42   virtual TabContents* AddBlankTabAt(int index, bool foreground) { | 43   virtual TabContentsWrapper* AddBlankTabAt(int index, bool foreground) { | 
| 43     return NULL; | 44     return NULL; | 
| 44   } | 45   } | 
| 45   virtual Browser* CreateNewStripWithContents(TabContents* contents, | 46   virtual Browser* CreateNewStripWithContents(TabContentsWrapper* contents, | 
| 46                                               const gfx::Rect& window_bounds, | 47                                               const gfx::Rect& window_bounds, | 
| 47                                               const DockInfo& dock_info, | 48                                               const DockInfo& dock_info, | 
| 48                                               bool maximize) { | 49                                               bool maximize) { | 
| 49     return NULL; | 50     return NULL; | 
| 50   } | 51   } | 
| 51   virtual void ContinueDraggingDetachedTab(TabContents* contents, | 52   virtual void ContinueDraggingDetachedTab(TabContentsWrapper* contents, | 
| 52                                          const gfx::Rect& window_bounds, | 53                                            const gfx::Rect& window_bounds, | 
| 53                                          const gfx::Rect& tab_bounds) { | 54                                            const gfx::Rect& tab_bounds) { | 
| 54   } | 55   } | 
| 55   virtual int GetDragActions() const { | 56   virtual int GetDragActions() const { | 
| 56     return 0; | 57     return 0; | 
| 57   } | 58   } | 
| 58   virtual TabContents* CreateTabContentsForURL( | 59   virtual TabContentsWrapper* CreateTabContentsForURL( | 
| 59       const GURL& url, | 60       const GURL& url, | 
| 60       const GURL& referrer, | 61       const GURL& referrer, | 
| 61       Profile* profile, | 62       Profile* profile, | 
| 62       PageTransition::Type transition, | 63       PageTransition::Type transition, | 
| 63       bool defer_load, | 64       bool defer_load, | 
| 64       SiteInstance* instance) const { | 65       SiteInstance* instance) const { | 
| 65     return NULL; | 66     return NULL; | 
| 66   } | 67   } | 
| 67   virtual bool CanDuplicateContentsAt(int index) { return true; } | 68   virtual bool CanDuplicateContentsAt(int index) { return true; } | 
| 68   virtual void DuplicateContentsAt(int index) { } | 69   virtual void DuplicateContentsAt(int index) { } | 
| 69   virtual void CloseFrameAfterDragSession() { } | 70   virtual void CloseFrameAfterDragSession() { } | 
| 70   virtual void CreateHistoricalTab(TabContents* contents) { } | 71   virtual void CreateHistoricalTab(TabContentsWrapper* contents) { } | 
| 71   virtual bool RunUnloadListenerBeforeClosing(TabContents* contents) { | 72   virtual bool RunUnloadListenerBeforeClosing(TabContentsWrapper* contents) { | 
| 72     return true; | 73     return true; | 
| 73   } | 74   } | 
| 74   virtual bool CanRestoreTab() { | 75   virtual bool CanRestoreTab() { | 
| 75     return true; | 76     return true; | 
| 76   } | 77   } | 
| 77   virtual void RestoreTab() {} | 78   virtual void RestoreTab() {} | 
| 78 | 79 | 
| 79   virtual bool CanCloseContentsAt(int index) { return true; } | 80   virtual bool CanCloseContentsAt(int index) { return true; } | 
| 80 | 81 | 
| 81   virtual bool CanBookmarkAllTabs() const { return false; } | 82   virtual bool CanBookmarkAllTabs() const { return false; } | 
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 145   scoped_nsobject<TestTabStripControllerDelegate> controller_delegate_; | 146   scoped_nsobject<TestTabStripControllerDelegate> controller_delegate_; | 
| 146   scoped_nsobject<TabStripController> controller_; | 147   scoped_nsobject<TabStripController> controller_; | 
| 147 }; | 148 }; | 
| 148 | 149 | 
| 149 // Test adding and removing tabs and making sure that views get added to | 150 // Test adding and removing tabs and making sure that views get added to | 
| 150 // the tab strip. | 151 // the tab strip. | 
| 151 TEST_F(TabStripControllerTest, AddRemoveTabs) { | 152 TEST_F(TabStripControllerTest, AddRemoveTabs) { | 
| 152   EXPECT_TRUE(model_->empty()); | 153   EXPECT_TRUE(model_->empty()); | 
| 153   SiteInstance* instance = | 154   SiteInstance* instance = | 
| 154       SiteInstance::CreateSiteInstance(browser_helper_.profile()); | 155       SiteInstance::CreateSiteInstance(browser_helper_.profile()); | 
| 155   TabContents* tab_contents = | 156   TabContentsWrapper* tab_contents = | 
| 156       new TabContents(browser_helper_.profile(), instance, MSG_ROUTING_NONE, | 157       Browser::TabContentsFactory(browser_helper_.profile(), instance, | 
| 157                       NULL, NULL); | 158           MSG_ROUTING_NONE, NULL, NULL); | 
| 158   model_->AppendTabContents(tab_contents, true); | 159   model_->AppendTabContents(tab_contents, true); | 
| 159   EXPECT_EQ(model_->count(), 1); | 160   EXPECT_EQ(model_->count(), 1); | 
| 160 } | 161 } | 
| 161 | 162 | 
| 162 TEST_F(TabStripControllerTest, SelectTab) { | 163 TEST_F(TabStripControllerTest, SelectTab) { | 
| 163   // TODO(pinkerton): Implement http://crbug.com/10899 | 164   // TODO(pinkerton): Implement http://crbug.com/10899 | 
| 164 } | 165 } | 
| 165 | 166 | 
| 166 TEST_F(TabStripControllerTest, RearrangeTabs) { | 167 TEST_F(TabStripControllerTest, RearrangeTabs) { | 
| 167   // TODO(pinkerton): Implement http://crbug.com/10899 | 168   // TODO(pinkerton): Implement http://crbug.com/10899 | 
| 168 } | 169 } | 
| 169 | 170 | 
| 170 // Test that changing the number of tabs broadcasts a | 171 // Test that changing the number of tabs broadcasts a | 
| 171 // kTabStripNumberOfTabsChanged notifiction. | 172 // kTabStripNumberOfTabsChanged notifiction. | 
| 172 TEST_F(TabStripControllerTest, Notifications) { | 173 TEST_F(TabStripControllerTest, Notifications) { | 
| 173   // TODO(pinkerton): Implement http://crbug.com/10899 | 174   // TODO(pinkerton): Implement http://crbug.com/10899 | 
| 174 } | 175 } | 
| 175 | 176 | 
| 176 }  // namespace | 177 }  // namespace | 
| OLD | NEW | 
|---|