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

Unified Diff: chrome/browser/ui/zoom/zoom_controller_browsertest.cc

Issue 393133002: Migrate HostZoomMap to live in StoragePartition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments; patch for landing. Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/zoom/zoom_controller.cc ('k') | chrome/browser/ui/zoom/zoom_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/zoom/zoom_controller_browsertest.cc
diff --git a/chrome/browser/ui/zoom/zoom_controller_browsertest.cc b/chrome/browser/ui/zoom/zoom_controller_browsertest.cc
index 36a2114897884339bf748231ec29b14cf79fadb5..4d0ffd51362cf99807cbdc350c50f998979f843c 100644
--- a/chrome/browser/ui/zoom/zoom_controller_browsertest.cc
+++ b/chrome/browser/ui/zoom/zoom_controller_browsertest.cc
@@ -20,8 +20,6 @@
#include "content/public/test/browser_test_utils.h"
#include "testing/gmock/include/gmock/gmock.h"
-typedef InProcessBrowserTest ZoomControllerBrowserTest;
-
bool operator==(const ZoomController::ZoomChangedEventData& lhs,
const ZoomController::ZoomChangedEventData& rhs) {
return lhs.web_contents == rhs.web_contents &&
@@ -59,7 +57,17 @@ class ZoomChangedWatcher : public ZoomObserver {
DISALLOW_COPY_AND_ASSIGN(ZoomChangedWatcher);
};
-// TODO(wjmaclean): Enable this on Android when we can kill the process there.
+class TestZoomObserver : public ZoomObserver {
+ public:
+ MOCK_METHOD1(OnZoomChanged,
+ void(const ZoomController::ZoomChangedEventData&));
+};
+
+class ZoomControllerBrowserTest: public InProcessBrowserTest {
+ protected:
+ TestZoomObserver zoom_observer_;
+};
+
#if defined(OS_ANDROID)
#define MAYBE_CrashedTabsDoNotChangeZoom DISABLED_CrashedTabsDoNotChangeZoom
#else
@@ -133,3 +141,28 @@ IN_PROC_BROWSER_TEST_F(ZoomControllerBrowserTest, ErrorPagesCanZoom) {
zoom_controller->SetZoomLevel(new_zoom_level);
EXPECT_FLOAT_EQ(new_zoom_level, zoom_controller->GetZoomLevel());
}
+
+IN_PROC_BROWSER_TEST_F(ZoomControllerBrowserTest, Observe) {
+ content::WebContents* web_contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ ZoomController* zoom_controller =
+ ZoomController::FromWebContents(web_contents);
+ zoom_controller->AddObserver(&zoom_observer_);
+
+ double new_zoom_level = 1.0;
+ // When the event is initiated from HostZoomMap, the old zoom level is not
+ // available.
+ ZoomController::ZoomChangedEventData zoom_change_data(
+ web_contents,
+ new_zoom_level,
+ new_zoom_level,
+ ZoomController::ZOOM_MODE_DEFAULT,
+ true); // We have a non-empty host, so this will be 'true'.
+ EXPECT_CALL(zoom_observer_, OnZoomChanged(zoom_change_data)).Times(1);
+
+ content::HostZoomMap* host_zoom_map =
+ content::HostZoomMap::GetDefaultForBrowserContext(
+ web_contents->GetBrowserContext());
+
+ host_zoom_map->SetZoomLevelForHost("about:blank", new_zoom_level);
+}
« no previous file with comments | « chrome/browser/ui/zoom/zoom_controller.cc ('k') | chrome/browser/ui/zoom/zoom_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698