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

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

Issue 11299014: [zoom bubble] Fix my stupidity and restore the proper host handling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test Created 8 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
Index: chrome/browser/ui/zoom/zoom_controller_unittest.cc
diff --git a/chrome/browser/ui/zoom/zoom_controller_unittest.cc b/chrome/browser/ui/zoom/zoom_controller_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4f57acfc771adf2ae502b3f1ca8894042b940b55
--- /dev/null
+++ b/chrome/browser/ui/zoom/zoom_controller_unittest.cc
@@ -0,0 +1,62 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/zoom/zoom_controller.h"
+#include "chrome/browser/ui/zoom/zoom_observer.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/test/base/chrome_render_view_host_test_harness.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/navigation_details.h"
+#include "content/public/browser/notification_details.h"
+#include "content/public/browser/notification_source.h"
+#include "content/public/browser/notification_types.h"
+#include "content/public/common/frame_navigate_params.h"
+#include "content/public/test/test_browser_thread.h"
+#include "content/public/test/test_renderer_host.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+typedef ChromeRenderViewHostTestHarness ZoomControllerTest;
+
+class TestZoomObserver : public ZoomObserver {
+ public:
+ MOCK_METHOD2(OnZoomChanged, void(content::WebContents*, bool));
+};
+
+TEST_F(ZoomControllerTest, DidNavigateMainFrame) {
+ ZoomController zoom_controller(web_contents());
+
+ TestZoomObserver zoom_observer;
+ zoom_controller.set_observer(&zoom_observer);
+
+ EXPECT_CALL(zoom_observer, OnZoomChanged(web_contents(), false)).Times(1);
+
+ zoom_controller.DidNavigateMainFrame(content::LoadCommittedDetails(),
+ content::FrameNavigateParams());
+}
+
+TEST_F(ZoomControllerTest, OnPreferenceChanged) {
+ ZoomController zoom_controller(web_contents());
+
+ TestZoomObserver zoom_observer;
+ zoom_controller.set_observer(&zoom_observer);
+
+ EXPECT_CALL(zoom_observer, OnZoomChanged(web_contents(), false)).Times(1);
+
+ zoom_controller.OnPreferenceChanged(NULL, prefs::kDefaultZoomLevel);
+}
+
+TEST_F(ZoomControllerTest, Observe) {
+ ZoomController zoom_controller(web_contents());
+
+ TestZoomObserver zoom_observer;
+ zoom_controller.set_observer(&zoom_observer);
+
+ EXPECT_CALL(zoom_observer, OnZoomChanged(web_contents(), false)).Times(1);
+
+ std::string host;
+ zoom_controller.Observe(content::NOTIFICATION_ZOOM_LEVEL_CHANGED,
+ content::Source<content::WebContents>(web_contents()),
+ content::Details<std::string>(&host));
+}

Powered by Google App Engine
This is Rietveld 408576698