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 #include <gtk/gtk.h> | 5 #include <gtk/gtk.h> |
6 | 6 |
7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
9 #include "chrome/browser/ui/browser_commands.h" | 9 #include "chrome/browser/ui/browser_commands.h" |
10 #include "chrome/browser/ui/browser_tabstrip.h" | |
11 #include "chrome/browser/ui/browser_window.h" | 10 #include "chrome/browser/ui/browser_window.h" |
12 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" | 11 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" |
13 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | 12 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
14 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" | 13 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" |
15 #include "chrome/browser/ui/gtk/view_id_util.h" | 14 #include "chrome/browser/ui/gtk/view_id_util.h" |
| 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
16 #include "chrome/browser/ui/zoom/zoom_controller.h" | 16 #include "chrome/browser/ui/zoom/zoom_controller.h" |
17 #include "chrome/test/base/in_process_browser_test.h" | 17 #include "chrome/test/base/in_process_browser_test.h" |
18 #include "chrome/test/base/ui_test_utils.h" | 18 #include "chrome/test/base/ui_test_utils.h" |
19 #include "content/public/browser/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
20 #include "content/public/browser/notification_types.h" | 20 #include "content/public/browser/notification_types.h" |
21 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
22 #include "content/public/common/page_zoom.h" | 22 #include "content/public/common/page_zoom.h" |
23 #include "grit/theme_resources.h" | 23 #include "grit/theme_resources.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
25 | 25 |
(...skipping 23 matching lines...) Expand all Loading... |
49 class LocationBarViewGtkZoomTest : public InProcessBrowserTest { | 49 class LocationBarViewGtkZoomTest : public InProcessBrowserTest { |
50 public: | 50 public: |
51 LocationBarViewGtkZoomTest() {} | 51 LocationBarViewGtkZoomTest() {} |
52 virtual ~LocationBarViewGtkZoomTest() {} | 52 virtual ~LocationBarViewGtkZoomTest() {} |
53 | 53 |
54 protected: | 54 protected: |
55 void ExpectTooltipContainsZoom() { | 55 void ExpectTooltipContainsZoom() { |
56 gchar* text = gtk_widget_get_tooltip_text(GetZoomWidget()); | 56 gchar* text = gtk_widget_get_tooltip_text(GetZoomWidget()); |
57 std::string tooltip(text); | 57 std::string tooltip(text); |
58 g_free(text); | 58 g_free(text); |
59 content::WebContents* contents = chrome::GetActiveWebContents(browser()); | 59 content::WebContents* contents = |
| 60 browser()->tab_strip_model()->GetActiveWebContents(); |
60 std::string zoom_percent = base::IntToString(GetZoomPercent(contents)); | 61 std::string zoom_percent = base::IntToString(GetZoomPercent(contents)); |
61 EXPECT_FALSE(tooltip.find(zoom_percent) == std::string::npos); | 62 EXPECT_FALSE(tooltip.find(zoom_percent) == std::string::npos); |
62 } | 63 } |
63 | 64 |
64 bool ZoomIconIsShowing() { | 65 bool ZoomIconIsShowing() { |
65 return gtk_widget_get_visible(GetZoomWidget()); | 66 return gtk_widget_get_visible(GetZoomWidget()); |
66 } | 67 } |
67 | 68 |
68 void ExpectIconIsResource(int resource_id) { | 69 void ExpectIconIsResource(int resource_id) { |
69 // TODO(dbeam): actually compare the image bits with gfx::test::IsEqual? | 70 // TODO(dbeam): actually compare the image bits with gfx::test::IsEqual? |
70 content::WebContents* contents = chrome::GetActiveWebContents(browser()); | 71 content::WebContents* contents = |
| 72 browser()->tab_strip_model()->GetActiveWebContents(); |
71 ZoomController* zoom_controller = ZoomController::FromWebContents(contents); | 73 ZoomController* zoom_controller = ZoomController::FromWebContents(contents); |
72 EXPECT_EQ(resource_id, zoom_controller->GetResourceForZoomLevel()); | 74 EXPECT_EQ(resource_id, zoom_controller->GetResourceForZoomLevel()); |
73 } | 75 } |
74 | 76 |
75 void ResetZoom() { | 77 void ResetZoom() { |
76 WaitForZoom(content::PAGE_ZOOM_RESET); | 78 WaitForZoom(content::PAGE_ZOOM_RESET); |
77 } | 79 } |
78 | 80 |
79 content::WebContents* SetUpTest() { | 81 content::WebContents* SetUpTest() { |
80 content::WebContents* contents = chrome::GetActiveWebContents(browser()); | 82 content::WebContents* contents = |
| 83 browser()->tab_strip_model()->GetActiveWebContents(); |
81 ResetZoom(); | 84 ResetZoom(); |
82 ExpectAtDefaultZoom(contents); | 85 ExpectAtDefaultZoom(contents); |
83 return contents; | 86 return contents; |
84 } | 87 } |
85 | 88 |
86 void ZoomIn() { | 89 void ZoomIn() { |
87 WaitForZoom(content::PAGE_ZOOM_IN); | 90 WaitForZoom(content::PAGE_ZOOM_IN); |
88 } | 91 } |
89 | 92 |
90 void ZoomOut() { | 93 void ZoomOut() { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 DCHECK_LT(GetZoomPercent(contents), zoom_level); | 166 DCHECK_LT(GetZoomPercent(contents), zoom_level); |
164 ExpectZoomedOut(contents); | 167 ExpectZoomedOut(contents); |
165 EXPECT_TRUE(ZoomIconIsShowing()); | 168 EXPECT_TRUE(ZoomIconIsShowing()); |
166 ExpectIconIsResource(IDR_ZOOM_MINUS); | 169 ExpectIconIsResource(IDR_ZOOM_MINUS); |
167 ExpectTooltipContainsZoom(); | 170 ExpectTooltipContainsZoom(); |
168 | 171 |
169 ResetZoom(); | 172 ResetZoom(); |
170 ExpectAtDefaultZoom(contents); | 173 ExpectAtDefaultZoom(contents); |
171 EXPECT_FALSE(ZoomIconIsShowing()); | 174 EXPECT_FALSE(ZoomIconIsShowing()); |
172 } | 175 } |
OLD | NEW |