Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/zoom/zoom_controller.h" | |
| 6 #include "chrome/browser/ui/zoom/zoom_observer.h" | |
| 7 #include "chrome/common/pref_names.h" | |
| 8 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | |
| 9 #include "content/public/browser/navigation_details.h" | |
| 10 #include "content/public/browser/notification_details.h" | |
| 11 #include "content/public/browser/notification_source.h" | |
| 12 #include "content/public/browser/notification_types.h" | |
| 13 #include "content/public/common/frame_navigate_params.h" | |
| 14 #include "testing/gmock/include/gmock/gmock.h" | |
| 15 #include "testing/gtest/include/gtest/gtest.h" | |
| 16 | |
| 17 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.
| |
| 18 | |
| 19 class TestZoomObserver : public ZoomObserver { | |
| 20 public: | |
| 21 MOCK_METHOD2(OnZoomChanged, void(content::WebContents*, bool)); | |
| 22 }; | |
| 23 | |
| 24 TEST_F(ZoomControllerTest, DidNavigateMainFrame) { | |
| 25 ZoomController zoom_controller(web_contents()); | |
| 26 | |
| 27 TestZoomObserver zoom_observer; | |
| 28 zoom_controller.set_observer(&zoom_observer); | |
| 29 | |
| 30 EXPECT_CALL(zoom_observer, OnZoomChanged(web_contents(), false)).Times(1); | |
| 31 | |
| 32 zoom_controller.DidNavigateMainFrame(content::LoadCommittedDetails(), | |
| 33 content::FrameNavigateParams()); | |
| 34 } | |
| 35 | |
| 36 TEST_F(ZoomControllerTest, OnPreferenceChanged) { | |
| 37 ZoomController zoom_controller(web_contents()); | |
| 38 | |
| 39 TestZoomObserver zoom_observer; | |
| 40 zoom_controller.set_observer(&zoom_observer); | |
| 41 | |
| 42 EXPECT_CALL(zoom_observer, OnZoomChanged(web_contents(), false)).Times(1); | |
| 43 | |
| 44 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.
| |
| 45 } | |
| 46 | |
| 47 TEST_F(ZoomControllerTest, Observe) { | |
| 48 ZoomController zoom_controller(web_contents()); | |
| 49 | |
| 50 TestZoomObserver zoom_observer; | |
| 51 zoom_controller.set_observer(&zoom_observer); | |
| 52 | |
| 53 EXPECT_CALL(zoom_observer, OnZoomChanged(web_contents(), false)).Times(1); | |
| 54 | |
| 55 std::string host; | |
| 56 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.
| |
| 57 content::Source<content::WebContents>(web_contents()), | |
| 58 content::Details<std::string>(&host)); | |
| 59 } | |
| OLD | NEW |