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

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

Issue 12039058: content: convert zoom notifications to observer usage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: callbacks Created 7 years, 10 months 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/message_loop.h" 5 #include "base/message_loop.h"
6 #include "chrome/browser/prefs/pref_service.h" 6 #include "chrome/browser/prefs/pref_service.h"
7 #include "chrome/browser/ui/browser.h" 7 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/ui/browser_finder.h" 8 #include "chrome/browser/ui/browser_finder.h"
9 #include "chrome/browser/ui/zoom/zoom_controller.h" 9 #include "chrome/browser/ui/zoom/zoom_controller.h"
10 #include "chrome/browser/ui/zoom/zoom_observer.h" 10 #include "chrome/browser/ui/zoom/zoom_observer.h"
11 #include "chrome/common/pref_names.h" 11 #include "chrome/common/pref_names.h"
12 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 12 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
13 #include "chrome/test/base/testing_profile.h" 13 #include "chrome/test/base/testing_profile.h"
14 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/host_zoom_map.h" 15 #include "content/public/browser/host_zoom_map.h"
16 #include "content/public/browser/navigation_details.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" 17 #include "content/public/common/frame_navigate_params.h"
21 #include "content/public/test/test_browser_thread.h" 18 #include "content/public/test/test_browser_thread.h"
22 #include "content/public/test/test_utils.h" 19 #include "content/public/test/test_utils.h"
23 #include "testing/gmock/include/gmock/gmock.h" 20 #include "testing/gmock/include/gmock/gmock.h"
24 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
25 22
26 class TestZoomObserver : public ZoomObserver { 23 class TestZoomObserver : public ZoomObserver {
27 public: 24 public:
28 MOCK_METHOD2(OnZoomChanged, void(content::WebContents*, bool)); 25 MOCK_METHOD2(OnZoomChanged, void(content::WebContents*, bool));
29 }; 26 };
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 profile()->GetPrefs()->SetDouble(prefs::kDefaultZoomLevel, 110.0f); 61 profile()->GetPrefs()->SetDouble(prefs::kDefaultZoomLevel, 110.0f);
65 } 62 }
66 63
67 TEST_F(ZoomControllerTest, Observe) { 64 TEST_F(ZoomControllerTest, Observe) {
68 EXPECT_CALL(zoom_observer_, OnZoomChanged(web_contents(), false)).Times(1); 65 EXPECT_CALL(zoom_observer_, OnZoomChanged(web_contents(), false)).Times(1);
69 66
70 content::HostZoomMap* host_zoom_map = 67 content::HostZoomMap* host_zoom_map =
71 content::HostZoomMap::GetForBrowserContext( 68 content::HostZoomMap::GetForBrowserContext(
72 web_contents()->GetBrowserContext()); 69 web_contents()->GetBrowserContext());
73 70
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); 71 host_zoom_map->SetZoomLevel(std::string(), 110.0f);
79
80 notification_observer.Wait();
jam 2013/01/30 17:50:44 can you update the test to verify that callbacks a
Paweł Hajdan Jr. 2013/01/31 16:02:15 It already does - see EXPECT_CALL above. The call
81 } 72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698