| 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #import "chrome/browser/ui/browser_window.h" | 9 #import "chrome/browser/ui/browser_window.h" |
| 10 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" | 10 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" |
| 11 #import "chrome/browser/ui/cocoa/new_tab_button.h" | 11 #import "chrome/browser/ui/cocoa/new_tab_button.h" |
| 12 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" | 12 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" |
| 13 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" | 13 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" |
| 14 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" | 14 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" |
| 15 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h" | 15 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h" |
| 16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 17 #include "content/browser/site_instance.h" | 17 #include "content/public/browser/site_instance.h" |
| 18 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 #include "testing/platform_test.h" | 20 #include "testing/platform_test.h" |
| 21 | 21 |
| 22 using content::SiteInstance; |
| 22 using content::WebContents; | 23 using content::WebContents; |
| 23 | 24 |
| 24 @interface TestTabStripControllerDelegate | 25 @interface TestTabStripControllerDelegate |
| 25 : NSObject<TabStripControllerDelegate> { | 26 : NSObject<TabStripControllerDelegate> { |
| 26 } | 27 } |
| 27 @end | 28 @end |
| 28 | 29 |
| 29 @implementation TestTabStripControllerDelegate | 30 @implementation TestTabStripControllerDelegate |
| 30 - (void)onActivateTabWithContents:(WebContents*)contents { | 31 - (void)onActivateTabWithContents:(WebContents*)contents { |
| 31 } | 32 } |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 TabStripModel* model_; | 162 TabStripModel* model_; |
| 162 scoped_nsobject<TestTabStripControllerDelegate> controller_delegate_; | 163 scoped_nsobject<TestTabStripControllerDelegate> controller_delegate_; |
| 163 scoped_nsobject<TabStripController> controller_; | 164 scoped_nsobject<TabStripController> controller_; |
| 164 scoped_nsobject<TabStripView> tab_strip_; | 165 scoped_nsobject<TabStripView> tab_strip_; |
| 165 }; | 166 }; |
| 166 | 167 |
| 167 // Test adding and removing tabs and making sure that views get added to | 168 // Test adding and removing tabs and making sure that views get added to |
| 168 // the tab strip. | 169 // the tab strip. |
| 169 TEST_F(TabStripControllerTest, AddRemoveTabs) { | 170 TEST_F(TabStripControllerTest, AddRemoveTabs) { |
| 170 EXPECT_TRUE(model_->empty()); | 171 EXPECT_TRUE(model_->empty()); |
| 171 SiteInstance* instance = SiteInstance::CreateSiteInstance(profile()); | 172 SiteInstance* instance = SiteInstance::Create(profile()); |
| 172 TabContentsWrapper* tab_contents = | 173 TabContentsWrapper* tab_contents = |
| 173 Browser::TabContentsFactory(profile(), instance, | 174 Browser::TabContentsFactory(profile(), instance, |
| 174 MSG_ROUTING_NONE, NULL, NULL); | 175 MSG_ROUTING_NONE, NULL, NULL); |
| 175 model_->AppendTabContents(tab_contents, true); | 176 model_->AppendTabContents(tab_contents, true); |
| 176 EXPECT_EQ(model_->count(), 1); | 177 EXPECT_EQ(model_->count(), 1); |
| 177 } | 178 } |
| 178 | 179 |
| 179 TEST_F(TabStripControllerTest, SelectTab) { | 180 TEST_F(TabStripControllerTest, SelectTab) { |
| 180 // TODO(pinkerton): Implement http://crbug.com/10899 | 181 // TODO(pinkerton): Implement http://crbug.com/10899 |
| 181 } | 182 } |
| 182 | 183 |
| 183 TEST_F(TabStripControllerTest, RearrangeTabs) { | 184 TEST_F(TabStripControllerTest, RearrangeTabs) { |
| 184 // TODO(pinkerton): Implement http://crbug.com/10899 | 185 // TODO(pinkerton): Implement http://crbug.com/10899 |
| 185 } | 186 } |
| 186 | 187 |
| 187 // Test that changing the number of tabs broadcasts a | 188 // Test that changing the number of tabs broadcasts a |
| 188 // kTabStripNumberOfTabsChanged notifiction. | 189 // kTabStripNumberOfTabsChanged notifiction. |
| 189 TEST_F(TabStripControllerTest, Notifications) { | 190 TEST_F(TabStripControllerTest, Notifications) { |
| 190 // TODO(pinkerton): Implement http://crbug.com/10899 | 191 // TODO(pinkerton): Implement http://crbug.com/10899 |
| 191 } | 192 } |
| 192 | 193 |
| 193 TEST_F(TabStripControllerTest, CorrectToolTipText) { | 194 TEST_F(TabStripControllerTest, CorrectToolTipText) { |
| 194 // Create tab 1. | 195 // Create tab 1. |
| 195 SiteInstance* instance = SiteInstance::CreateSiteInstance(profile()); | 196 SiteInstance* instance = SiteInstance::Create(profile()); |
| 196 TabContentsWrapper* tab_contents = | 197 TabContentsWrapper* tab_contents = |
| 197 Browser::TabContentsFactory(profile(), instance, | 198 Browser::TabContentsFactory(profile(), instance, |
| 198 MSG_ROUTING_NONE, NULL, NULL); | 199 MSG_ROUTING_NONE, NULL, NULL); |
| 199 model_->AppendTabContents(tab_contents, true); | 200 model_->AppendTabContents(tab_contents, true); |
| 200 | 201 |
| 201 // Create tab 2. | 202 // Create tab 2. |
| 202 SiteInstance* instance2 = SiteInstance::CreateSiteInstance(profile()); | 203 SiteInstance* instance2 = SiteInstance::Create(profile()); |
| 203 TabContentsWrapper* tab_contents2 = | 204 TabContentsWrapper* tab_contents2 = |
| 204 Browser::TabContentsFactory(profile(), instance2, | 205 Browser::TabContentsFactory(profile(), instance2, |
| 205 MSG_ROUTING_NONE, NULL, NULL); | 206 MSG_ROUTING_NONE, NULL, NULL); |
| 206 model_->AppendTabContents(tab_contents2, true); | 207 model_->AppendTabContents(tab_contents2, true); |
| 207 | 208 |
| 208 // Set tab 1 tooltip. | 209 // Set tab 1 tooltip. |
| 209 TabView* tab1 = (TabView*)[controller_.get() viewAtIndex:0]; | 210 TabView* tab1 = (TabView*)[controller_.get() viewAtIndex:0]; |
| 210 [tab1 setToolTip:@"Tab1"]; | 211 [tab1 setToolTip:@"Tab1"]; |
| 211 | 212 |
| 212 // Set tab 2 tooltip. | 213 // Set tab 2 tooltip. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 | 282 |
| 282 [controller_.get() mouseMoved:event]; | 283 [controller_.get() mouseMoved:event]; |
| 283 EXPECT_STREQ("Tab2", | 284 EXPECT_STREQ("Tab2", |
| 284 [[controller_ view:nil | 285 [[controller_ view:nil |
| 285 stringForToolTip:nil | 286 stringForToolTip:nil |
| 286 point:NSMakePoint(0,0) | 287 point:NSMakePoint(0,0) |
| 287 userData:nil] cStringUsingEncoding:NSASCIIStringEncoding]); | 288 userData:nil] cStringUsingEncoding:NSASCIIStringEncoding]); |
| 288 } | 289 } |
| 289 | 290 |
| 290 } // namespace | 291 } // namespace |
| OLD | NEW |