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

Side by Side Diff: chrome/browser/ui/zoom/zoom_controller_unittest.cc

Issue 11414018: [zoom bubble] Add tests for ZoomController::UpdateState() handling empty hosts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/zoom/zoom_controller.cc ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 "base/message_loop.h"
6 #include "chrome/browser/prefs/pref_service.h"
7 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/ui/browser_finder.h"
9 #include "chrome/browser/ui/zoom/zoom_controller.h"
10 #include "chrome/browser/ui/zoom/zoom_observer.h"
11 #include "chrome/common/pref_names.h"
12 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
13 #include "chrome/test/base/testing_profile.h"
14 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/host_zoom_map.h"
16 #include "content/public/browser/navigation_details.h"
17 #include "content/public/browser/notification_details.h"
18 #include "content/public/browser/notification_source.h"
19 #include "content/public/browser/notification_types.h"
20 #include "content/public/common/frame_navigate_params.h"
21 #include "content/public/test/test_browser_thread.h"
22 #include "content/public/test/test_utils.h"
23 #include "testing/gmock/include/gmock/gmock.h"
24 #include "testing/gtest/include/gtest/gtest.h"
25
26 class TestZoomObserver : public ZoomObserver {
27 public:
28 MOCK_METHOD2(OnZoomChanged, void(content::WebContents*, bool));
29 };
30
31 class ZoomControllerTest : public ChromeRenderViewHostTestHarness {
32 public:
33 ZoomControllerTest()
34 : ui_thread_(content::BrowserThread::UI, MessageLoop::current()) {}
35
36 virtual void SetUp() OVERRIDE {
37 ChromeRenderViewHostTestHarness::SetUp();
38 zoom_controller_.reset(new ZoomController(web_contents()));
39 zoom_controller_->set_observer(&zoom_observer_);
40 }
41
42 virtual void TearDown() OVERRIDE {
43 zoom_controller_.reset();
44 ChromeRenderViewHostTestHarness::TearDown();
45 }
46
47 protected:
48 scoped_ptr<ZoomController> zoom_controller_;
49 TestZoomObserver zoom_observer_;
50
51 private:
52 content::TestBrowserThread ui_thread_;
53 DISALLOW_COPY_AND_ASSIGN(ZoomControllerTest);
54 };
55
56 TEST_F(ZoomControllerTest, DidNavigateMainFrame) {
57 EXPECT_CALL(zoom_observer_, OnZoomChanged(web_contents(), false)).Times(1);
58 zoom_controller_->DidNavigateMainFrame(content::LoadCommittedDetails(),
59 content::FrameNavigateParams());
60 }
61
62 TEST_F(ZoomControllerTest, OnPreferenceChanged) {
63 EXPECT_CALL(zoom_observer_, OnZoomChanged(web_contents(), false)).Times(1);
64 profile()->GetPrefs()->SetDouble(prefs::kDefaultZoomLevel, 110.0f);
65 }
66
67 TEST_F(ZoomControllerTest, Observe) {
68 EXPECT_CALL(zoom_observer_, OnZoomChanged(web_contents(), false)).Times(1);
69
70 content::HostZoomMap* host_zoom_map =
71 content::HostZoomMap::GetForBrowserContext(
72 web_contents()->GetBrowserContext());
73
74 content::WindowedNotificationObserver notification_observer(
75 content::NOTIFICATION_ZOOM_LEVEL_CHANGED,
76 content::NotificationService::AllSources());
77
78 host_zoom_map->SetZoomLevel(std::string(), 110.0f);
79
80 notification_observer.Wait();
81 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/zoom/zoom_controller.cc ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698