Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Side by Side Diff: chrome/browser/ui/views/frame/browser_view_unittest.cc

Issue 138943006: Remove a bunch of dead files after the win aura switch. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/ui/views/frame/browser_view.h" 5 #include "chrome/browser/ui/views/frame/browser_view.h"
6 6
7 #include "chrome/app/chrome_command_ids.h" 7 #include "chrome/app/chrome_command_ids.h"
8 #include "chrome/browser/ui/browser_commands.h" 8 #include "chrome/browser/ui/browser_commands.h"
9 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" 9 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
10 #include "chrome/browser/ui/views/frame/browser_view_layout.h" 10 #include "chrome/browser/ui/views/frame/browser_view_layout.h"
11 #include "chrome/browser/ui/views/frame/test_with_browser_view.h" 11 #include "chrome/browser/ui/views/frame/test_with_browser_view.h"
12 #include "chrome/browser/ui/views/frame/top_container_view.h" 12 #include "chrome/browser/ui/views/frame/top_container_view.h"
13 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" 13 #include "chrome/browser/ui/views/infobars/infobar_container_view.h"
14 #include "chrome/browser/ui/views/tabs/tab_strip.h" 14 #include "chrome/browser/ui/views/tabs/tab_strip.h"
15 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" 15 #include "chrome/browser/ui/views/toolbar/toolbar_view.h"
16 #include "chrome/common/url_constants.h" 16 #include "chrome/common/url_constants.h"
17 #include "grit/generated_resources.h"
17 #include "grit/theme_resources.h" 18 #include "grit/theme_resources.h"
19 #include "ui/base/resource/resource_bundle.h"
18 #include "ui/views/controls/single_split_view.h" 20 #include "ui/views/controls/single_split_view.h"
19 #include "ui/views/controls/webview/webview.h" 21 #include "ui/views/controls/webview/webview.h"
20 22
21 #if defined(OS_WIN)
22 #include "chrome/browser/ui/views/frame/browser_frame_win.h"
23 #endif
24
25 namespace { 23 namespace {
26 24
27 // Tab strip bounds depend on the window frame sizes. 25 // Tab strip bounds depend on the window frame sizes.
28 gfx::Point ExpectedTabStripOrigin(BrowserView* browser_view) { 26 gfx::Point ExpectedTabStripOrigin(BrowserView* browser_view) {
29 gfx::Rect tabstrip_bounds( 27 gfx::Rect tabstrip_bounds(
30 browser_view->frame()->GetBoundsForTabStrip(browser_view->tabstrip())); 28 browser_view->frame()->GetBoundsForTabStrip(browser_view->tabstrip()));
31 gfx::Point tabstrip_origin(tabstrip_bounds.origin()); 29 gfx::Point tabstrip_origin(tabstrip_bounds.origin());
32 views::View::ConvertPointToTarget(browser_view->parent(), 30 views::View::ConvertPointToTarget(browser_view->parent(),
33 browser_view, 31 browser_view,
34 &tabstrip_origin); 32 &tabstrip_origin);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 EXPECT_FALSE(bookmark_bar->visible()); 157 EXPECT_FALSE(bookmark_bar->visible());
160 EXPECT_FALSE(bookmark_bar->IsDetached()); 158 EXPECT_FALSE(bookmark_bar->IsDetached());
161 EXPECT_EQ(top_container, bookmark_bar->parent()); 159 EXPECT_EQ(top_container, bookmark_bar->parent());
162 // Top container is still second from front. 160 // Top container is still second from front.
163 EXPECT_EQ(browser_view()->child_count() - 2, 161 EXPECT_EQ(browser_view()->child_count() - 2,
164 browser_view()->GetIndexOf(top_container)); 162 browser_view()->GetIndexOf(top_container));
165 163
166 BookmarkBarView::DisableAnimationsForTesting(false); 164 BookmarkBarView::DisableAnimationsForTesting(false);
167 } 165 }
168 166
169 #if defined(OS_WIN) && !defined(USE_AURA) 167 #if defined(OS_WIN)
170 168
171 // This class provides functionality to test the incognito window/normal window 169 // This class provides functionality to test the incognito window/normal window
172 // switcher button which is added to Windows 8 metro Chrome. 170 // switcher button which is added to Windows 8 metro Chrome.
173 // We create the BrowserView ourselves in the 171 // We create the BrowserView ourselves in the
174 // BrowserWithTestWindowTest::CreateBrowserWindow function override and add the 172 // BrowserWithTestWindowTest::CreateBrowserWindow function override and add the
175 // switcher button to the view. We also provide an incognito profile to ensure 173 // switcher button to the view. We also provide an incognito profile to ensure
176 // that the switcher button is visible. 174 // that the switcher button is visible.
177 class BrowserViewIncognitoSwitcherTest : public TestWithBrowserView { 175 class BrowserViewIncognitoSwitcherTest : public TestWithBrowserView {
178 public: 176 public:
179 // Subclass of BrowserView, which overrides the GetRestoreBounds/IsMaximized 177 // Subclass of BrowserView, which overrides the GetRestoreBounds/IsMaximized
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 virtual BrowserWindow* CreateBrowserWindow() OVERRIDE { 214 virtual BrowserWindow* CreateBrowserWindow() OVERRIDE {
217 // We need an incognito profile for the window switcher button to be 215 // We need an incognito profile for the window switcher button to be
218 // visible. 216 // visible.
219 // This profile instance is owned by the TestingProfile instance within the 217 // This profile instance is owned by the TestingProfile instance within the
220 // BrowserWithTestWindowTest class. 218 // BrowserWithTestWindowTest class.
221 TestingProfile::Builder builder; 219 TestingProfile::Builder builder;
222 builder.SetIncognito(); 220 builder.SetIncognito();
223 GetProfile()->SetOffTheRecordProfile(builder.Build()); 221 GetProfile()->SetOffTheRecordProfile(builder.Build());
224 222
225 browser_view_ = new TestBrowserView(); 223 browser_view_ = new TestBrowserView();
226 browser_view_->SetWindowSwitcherButton( 224
227 MakeWindowSwitcherButton(NULL, false)); 225 views::ImageButton* switcher_button = new views::ImageButton(NULL);
226 // The button in the incognito window has the hot-cold images inverted
227 // with respect to the regular browser window.
228 switcher_button->SetImage(
229 views::ImageButton::STATE_NORMAL,
230 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
231 IDR_INCOGNITO_SWITCH_OFF));
232 switcher_button->SetImage(
233 views::ImageButton::STATE_HOVERED,
234 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
235 IDR_INCOGNITO_SWITCH_ON));
236 switcher_button->SetImageAlignment(views::ImageButton::ALIGN_CENTER,
237 views::ImageButton::ALIGN_MIDDLE);
238
239 browser_view_->SetWindowSwitcherButton(switcher_button);
228 return browser_view_; 240 return browser_view_;
229 } 241 }
230 242
231 private: 243 private:
232 BrowserView* browser_view_; 244 BrowserView* browser_view_;
233 245
234 DISALLOW_COPY_AND_ASSIGN(BrowserViewIncognitoSwitcherTest); 246 DISALLOW_COPY_AND_ASSIGN(BrowserViewIncognitoSwitcherTest);
235 }; 247 };
236 248
237 // Test whether the windows incognito/normal browser window switcher button 249 // Test whether the windows incognito/normal browser window switcher button
238 // is the event handler for a point within its bounds. The event handler for 250 // is the event handler for a point within its bounds. The event handler for
239 // a point in the View class is dependent on the order in which children are 251 // a point in the View class is dependent on the order in which children are
240 // added to it. This test ensures that we don't regress in the window switcher 252 // added to it. This test ensures that we don't regress in the window switcher
241 // functionality when additional children are added to the BrowserView class. 253 // functionality when additional children are added to the BrowserView class.
242 TEST_F(BrowserViewIncognitoSwitcherTest, 254 TEST_F(BrowserViewIncognitoSwitcherTest,
243 BrowserViewIncognitoSwitcherEventHandlerTest) { 255 BrowserViewIncognitoSwitcherEventHandlerTest) {
244 // |browser_view_| owns the Browser, not the test class. 256 // |browser_view_| owns the Browser, not the test class.
245 EXPECT_FALSE(browser());
246 EXPECT_TRUE(browser_view()->browser()); 257 EXPECT_TRUE(browser_view()->browser());
247 // Test initial state. 258 // Test initial state.
248 EXPECT_TRUE(browser_view()->IsTabStripVisible()); 259 EXPECT_TRUE(browser_view()->IsTabStripVisible());
249 // Validate whether the window switcher button is the target for the position 260 // Validate whether the window switcher button is the target for the position
250 // passed in. 261 // passed in.
251 gfx::Point switcher_point(browser_view()->window_switcher_button()->x() + 2, 262 gfx::Point switcher_point(browser_view()->window_switcher_button()->x() + 2,
252 browser_view()->window_switcher_button()->y()); 263 browser_view()->window_switcher_button()->y());
253 EXPECT_EQ(browser_view()->GetEventHandlerForPoint(switcher_point), 264 EXPECT_EQ(browser_view()->GetEventHandlerForPoint(switcher_point),
254 browser_view()->window_switcher_button()); 265 browser_view()->window_switcher_button());
255 } 266 }
256 #endif 267 #endif
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_frame_win.cc ('k') | chrome/browser/ui/views/frame/glass_browser_frame_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698