| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_controller.h" | 12 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h" |
| 13 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" | 13 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" |
| 14 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" | 14 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" |
| 15 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" | 15 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" |
| 16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 16 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 17 #include "chrome/browser/ui/tabs/test_tab_strip_model_delegate.h" | 17 #include "chrome/browser/ui/tabs/test_tab_strip_model_delegate.h" |
| 18 #include "content/public/browser/site_instance.h" | 18 #include "content/public/browser/site_instance.h" |
| 19 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 21 #include "testing/platform_test.h" | 21 #include "testing/platform_test.h" |
| 22 | 22 |
| 23 using content::SiteInstance; | 23 using content::SiteInstance; |
| 24 using content::WebContents; | 24 using content::WebContents; |
| 25 | 25 |
| 26 @interface TestTabStripControllerDelegate | 26 @interface TestTabStripControllerDelegate |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 scoped_nsobject<TestTabStripControllerDelegate> controller_delegate_; | 110 scoped_nsobject<TestTabStripControllerDelegate> controller_delegate_; |
| 111 scoped_nsobject<TabStripController> controller_; | 111 scoped_nsobject<TabStripController> controller_; |
| 112 scoped_nsobject<TabStripView> tab_strip_; | 112 scoped_nsobject<TabStripView> tab_strip_; |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 // Test adding and removing tabs and making sure that views get added to | 115 // Test adding and removing tabs and making sure that views get added to |
| 116 // the tab strip. | 116 // the tab strip. |
| 117 TEST_F(TabStripControllerTest, AddRemoveTabs) { | 117 TEST_F(TabStripControllerTest, AddRemoveTabs) { |
| 118 EXPECT_TRUE(model_->empty()); | 118 EXPECT_TRUE(model_->empty()); |
| 119 SiteInstance* instance = SiteInstance::Create(profile()); | 119 SiteInstance* instance = SiteInstance::Create(profile()); |
| 120 TabContentsWrapper* tab_contents = | 120 TabContents* tab_contents = |
| 121 Browser::TabContentsFactory(profile(), instance, | 121 Browser::TabContentsFactory(profile(), instance, |
| 122 MSG_ROUTING_NONE, NULL, NULL); | 122 MSG_ROUTING_NONE, NULL, NULL); |
| 123 model_->AppendTabContents(tab_contents, true); | 123 model_->AppendTabContents(tab_contents, true); |
| 124 EXPECT_EQ(model_->count(), 1); | 124 EXPECT_EQ(model_->count(), 1); |
| 125 } | 125 } |
| 126 | 126 |
| 127 TEST_F(TabStripControllerTest, SelectTab) { | 127 TEST_F(TabStripControllerTest, SelectTab) { |
| 128 // TODO(pinkerton): Implement http://crbug.com/10899 | 128 // TODO(pinkerton): Implement http://crbug.com/10899 |
| 129 } | 129 } |
| 130 | 130 |
| 131 TEST_F(TabStripControllerTest, RearrangeTabs) { | 131 TEST_F(TabStripControllerTest, RearrangeTabs) { |
| 132 // TODO(pinkerton): Implement http://crbug.com/10899 | 132 // TODO(pinkerton): Implement http://crbug.com/10899 |
| 133 } | 133 } |
| 134 | 134 |
| 135 TEST_F(TabStripControllerTest, CorrectToolTipText) { | 135 TEST_F(TabStripControllerTest, CorrectToolTipText) { |
| 136 // Create tab 1. | 136 // Create tab 1. |
| 137 SiteInstance* instance = SiteInstance::Create(profile()); | 137 SiteInstance* instance = SiteInstance::Create(profile()); |
| 138 TabContentsWrapper* tab_contents = | 138 TabContents* tab_contents = |
| 139 Browser::TabContentsFactory(profile(), instance, | 139 Browser::TabContentsFactory(profile(), instance, |
| 140 MSG_ROUTING_NONE, NULL, NULL); | 140 MSG_ROUTING_NONE, NULL, NULL); |
| 141 model_->AppendTabContents(tab_contents, true); | 141 model_->AppendTabContents(tab_contents, true); |
| 142 | 142 |
| 143 // Create tab 2. | 143 // Create tab 2. |
| 144 SiteInstance* instance2 = SiteInstance::Create(profile()); | 144 SiteInstance* instance2 = SiteInstance::Create(profile()); |
| 145 TabContentsWrapper* tab_contents2 = | 145 TabContents* tab_contents2 = |
| 146 Browser::TabContentsFactory(profile(), instance2, | 146 Browser::TabContentsFactory(profile(), instance2, |
| 147 MSG_ROUTING_NONE, NULL, NULL); | 147 MSG_ROUTING_NONE, NULL, NULL); |
| 148 model_->AppendTabContents(tab_contents2, true); | 148 model_->AppendTabContents(tab_contents2, true); |
| 149 | 149 |
| 150 // Set tab 1 tooltip. | 150 // Set tab 1 tooltip. |
| 151 TabView* tab1 = (TabView*)[controller_.get() viewAtIndex:0]; | 151 TabView* tab1 = (TabView*)[controller_.get() viewAtIndex:0]; |
| 152 [tab1 setToolTip:@"Tab1"]; | 152 [tab1 setToolTip:@"Tab1"]; |
| 153 | 153 |
| 154 // Set tab 2 tooltip. | 154 // Set tab 2 tooltip. |
| 155 TabView* tab2 = (TabView*)[controller_.get() viewAtIndex:1]; | 155 TabView* tab2 = (TabView*)[controller_.get() viewAtIndex:1]; |
| 156 [tab2 setToolTip:@"Tab2"]; | 156 [tab2 setToolTip:@"Tab2"]; |
| 157 | 157 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 | 223 |
| 224 [controller_.get() mouseMoved:event]; | 224 [controller_.get() mouseMoved:event]; |
| 225 EXPECT_STREQ("Tab2", | 225 EXPECT_STREQ("Tab2", |
| 226 [[controller_ view:nil | 226 [[controller_ view:nil |
| 227 stringForToolTip:nil | 227 stringForToolTip:nil |
| 228 point:NSMakePoint(0,0) | 228 point:NSMakePoint(0,0) |
| 229 userData:nil] cStringUsingEncoding:NSASCIIStringEncoding]); | 229 userData:nil] cStringUsingEncoding:NSASCIIStringEncoding]); |
| 230 } | 230 } |
| 231 | 231 |
| 232 } // namespace | 232 } // namespace |
| OLD | NEW |