| 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/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_commands.h" | 10 #include "chrome/browser/ui/browser_commands.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 GtkWidget* GetZoomWidget() { | 105 GtkWidget* GetZoomWidget() { |
| 106 gfx::NativeWindow window = browser()->window()->GetNativeWindow(); | 106 gfx::NativeWindow window = browser()->window()->GetNativeWindow(); |
| 107 return ViewIDUtil::GetWidget(GTK_WIDGET(window), VIEW_ID_ZOOM_BUTTON); | 107 return ViewIDUtil::GetWidget(GTK_WIDGET(window), VIEW_ID_ZOOM_BUTTON); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void WaitForZoom(content::PageZoom zoom_action) { | 110 void WaitForZoom(content::PageZoom zoom_action) { |
| 111 scoped_refptr<content::MessageLoopRunner> loop_runner( | 111 scoped_refptr<content::MessageLoopRunner> loop_runner( |
| 112 new content::MessageLoopRunner); | 112 new content::MessageLoopRunner); |
| 113 content::HostZoomMap::ZoomLevelChangedCallback callback( | 113 content::HostZoomMap::ZoomLevelChangedCallback callback( |
| 114 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure())); | 114 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure())); |
| 115 content::HostZoomMap::GetForBrowserContext( | 115 scoped_ptr<content::HostZoomMap::Subscription> sub = |
| 116 browser()->profile())->AddZoomLevelChangedCallback(callback); | 116 content::HostZoomMap::GetForBrowserContext( |
| 117 browser()->profile())->AddZoomLevelChangedCallback(callback); |
| 117 chrome::Zoom(browser(), zoom_action); | 118 chrome::Zoom(browser(), zoom_action); |
| 118 loop_runner->Run(); | 119 loop_runner->Run(); |
| 119 content::HostZoomMap::GetForBrowserContext( | |
| 120 browser()->profile())->RemoveZoomLevelChangedCallback(callback); | |
| 121 } | 120 } |
| 122 | 121 |
| 123 DISALLOW_COPY_AND_ASSIGN(LocationBarViewGtkZoomTest); | 122 DISALLOW_COPY_AND_ASSIGN(LocationBarViewGtkZoomTest); |
| 124 }; | 123 }; |
| 125 | 124 |
| 126 IN_PROC_BROWSER_TEST_F(LocationBarViewGtkZoomTest, DefaultToZoomedInAndBack) { | 125 IN_PROC_BROWSER_TEST_F(LocationBarViewGtkZoomTest, DefaultToZoomedInAndBack) { |
| 127 content::WebContents* contents = SetUpTest(); | 126 content::WebContents* contents = SetUpTest(); |
| 128 | 127 |
| 129 ZoomIn(); | 128 ZoomIn(); |
| 130 ExpectZoomedIn(contents); | 129 ExpectZoomedIn(contents); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 DCHECK_LT(GetZoomPercent(contents), zoom_level); | 177 DCHECK_LT(GetZoomPercent(contents), zoom_level); |
| 179 ExpectZoomedOut(contents); | 178 ExpectZoomedOut(contents); |
| 180 EXPECT_TRUE(ZoomIconIsShowing()); | 179 EXPECT_TRUE(ZoomIconIsShowing()); |
| 181 ExpectIconIsResource(IDR_ZOOM_MINUS); | 180 ExpectIconIsResource(IDR_ZOOM_MINUS); |
| 182 ExpectTooltipContainsZoom(); | 181 ExpectTooltipContainsZoom(); |
| 183 | 182 |
| 184 ResetZoom(); | 183 ResetZoom(); |
| 185 ExpectAtDefaultZoom(contents); | 184 ExpectAtDefaultZoom(contents); |
| 186 EXPECT_FALSE(ZoomIconIsShowing()); | 185 EXPECT_FALSE(ZoomIconIsShowing()); |
| 187 } | 186 } |
| OLD | NEW |