Chromium Code Reviews| 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..bc0798b9deb22fad065b2b830185cd431045a9bf |
| --- /dev/null |
| +++ b/chrome/browser/ui/zoom/zoom_controller_unittest.cc |
| @@ -0,0 +1,59 @@ |
| +// 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/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 "testing/gmock/include/gmock/gmock.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +typedef ChromeRenderViewHostTestHarness ZoomControllerTest; |
|
Evan Stade
2012/11/16 18:34:43
instead of just a typedef, create a ZoomController
Dan Beam
2012/11/17 01:20:32
Done.
|
| + |
| +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); |
|
Evan Stade
2012/11/16 18:34:43
could you actually change the preference instead o
Dan Beam
2012/11/17 01:20:32
Done.
|
| +} |
| + |
| +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, |
|
Evan Stade
2012/11/16 18:34:43
likewise, is it possible to get the HostZoomMap an
Dan Beam
2012/11/17 01:20:32
Done.
|
| + content::Source<content::WebContents>(web_contents()), |
| + content::Details<std::string>(&host)); |
| +} |