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

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

Issue 529993002: Use IsRenderViewLive() to test for SadTab in ZoomController. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to r292920. Created 6 years, 3 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/ui/zoom/zoom_controller.h" 5 #include "chrome/browser/ui/zoom/zoom_controller.h"
6 6
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "base/process/kill.h" 8 #include "base/process/kill.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" 11 #include "chrome/browser/ui/tabs/tab_strip_model.h"
12 #include "chrome/common/pref_names.h" 12 #include "chrome/common/pref_names.h"
13 #include "chrome/test/base/in_process_browser_test.h" 13 #include "chrome/test/base/in_process_browser_test.h"
14 #include "chrome/test/base/ui_test_utils.h" 14 #include "chrome/test/base/ui_test_utils.h"
15 #include "content/public/browser/render_process_host.h" 15 #include "content/public/browser/render_process_host.h"
16 #include "content/public/browser/render_view_host.h"
16 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
17 #include "content/public/test/browser_test_utils.h" 18 #include "content/public/test/browser_test_utils.h"
18 #include "testing/gmock/include/gmock/gmock.h" 19 #include "testing/gmock/include/gmock/gmock.h"
19 20
20 typedef InProcessBrowserTest ZoomControllerBrowserTest; 21 typedef InProcessBrowserTest ZoomControllerBrowserTest;
21 22
22 bool operator==(const ZoomController::ZoomChangedEventData& lhs, 23 bool operator==(const ZoomController::ZoomChangedEventData& lhs,
23 const ZoomController::ZoomChangedEventData& rhs) { 24 const ZoomController::ZoomChangedEventData& rhs) {
24 return lhs.web_contents == rhs.web_contents && 25 return lhs.web_contents == rhs.web_contents &&
25 lhs.old_zoom_level == rhs.old_zoom_level && 26 lhs.old_zoom_level == rhs.old_zoom_level &&
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 double old_zoom_level = zoom_controller->GetZoomLevel(); 75 double old_zoom_level = zoom_controller->GetZoomLevel();
75 double new_zoom_level = old_zoom_level + 0.5; 76 double new_zoom_level = old_zoom_level + 0.5;
76 77
77 content::RenderProcessHost* host = web_contents->GetRenderProcessHost(); 78 content::RenderProcessHost* host = web_contents->GetRenderProcessHost();
78 { 79 {
79 content::RenderProcessHostWatcher crash_observer( 80 content::RenderProcessHostWatcher crash_observer(
80 host, content::RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); 81 host, content::RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT);
81 base::KillProcess(host->GetHandle(), 0, false); 82 base::KillProcess(host->GetHandle(), 0, false);
82 crash_observer.Wait(); 83 crash_observer.Wait();
83 } 84 }
84 EXPECT_FALSE(web_contents->GetRenderProcessHost()->HasConnection()); 85 EXPECT_FALSE(web_contents->GetRenderViewHost()->IsRenderViewLive());
85 86
86 // The following attempt to change the zoom level for a crashed tab should 87 // The following attempt to change the zoom level for a crashed tab should
87 // fail. 88 // fail.
88 zoom_controller->SetZoomLevel(new_zoom_level); 89 zoom_controller->SetZoomLevel(new_zoom_level);
89 EXPECT_FLOAT_EQ(old_zoom_level, zoom_controller->GetZoomLevel()); 90 EXPECT_FLOAT_EQ(old_zoom_level, zoom_controller->GetZoomLevel());
90 } 91 }
91 92
92 IN_PROC_BROWSER_TEST_F(ZoomControllerBrowserTest, OnPreferenceChanged) { 93 IN_PROC_BROWSER_TEST_F(ZoomControllerBrowserTest, OnPreferenceChanged) {
93 content::WebContents* web_contents = 94 content::WebContents* web_contents =
94 browser()->tab_strip_model()->GetActiveWebContents(); 95 browser()->tab_strip_model()->GetActiveWebContents();
95 double new_default_zoom_level = 1.0; 96 double new_default_zoom_level = 1.0;
96 // Since this page uses the default zoom level, the changes to the default 97 // Since this page uses the default zoom level, the changes to the default
97 // zoom level will change the zoom level for this web_contents. 98 // zoom level will change the zoom level for this web_contents.
98 ZoomController::ZoomChangedEventData zoom_change_data( 99 ZoomController::ZoomChangedEventData zoom_change_data(
99 web_contents, 100 web_contents,
100 new_default_zoom_level, 101 new_default_zoom_level,
101 new_default_zoom_level, 102 new_default_zoom_level,
102 ZoomController::ZOOM_MODE_DEFAULT, 103 ZoomController::ZOOM_MODE_DEFAULT,
103 true); 104 true);
104 ZoomChangedWatcher zoom_change_watcher(web_contents, zoom_change_data); 105 ZoomChangedWatcher zoom_change_watcher(web_contents, zoom_change_data);
105 // TODO(wjmaclean): Convert this to call partition-specific zoom level prefs 106 // TODO(wjmaclean): Convert this to call partition-specific zoom level prefs
106 // when they become available. 107 // when they become available.
107 browser()->profile()->GetPrefs()->SetDouble(prefs::kDefaultZoomLevel, 108 browser()->profile()->GetPrefs()->SetDouble(prefs::kDefaultZoomLevel,
108 new_default_zoom_level); 109 new_default_zoom_level);
109 // Because this test relies on a round-trip IPC to/from the renderer process, 110 // Because this test relies on a round-trip IPC to/from the renderer process,
110 // we need to wait for it to propagate. 111 // we need to wait for it to propagate.
111 zoom_change_watcher.Wait(); 112 zoom_change_watcher.Wait();
112 } 113 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/zoom/zoom_controller.cc ('k') | chrome/browser/ui/zoom/zoom_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698