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

Unified Diff: chrome/browser/ui/tabs/tab_strip_model_unittest.cc

Issue 2630583002: Add setting to isolate zoom changes by default. (Closed)
Patch Set: ... and tell closure_compiler. Created 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/tabs/tab_strip_model_unittest.cc
diff --git a/chrome/browser/ui/tabs/tab_strip_model_unittest.cc b/chrome/browser/ui/tabs/tab_strip_model_unittest.cc
index f040375f844bf6032b3b6167f6aa9f4a93631bdf..590d4dbacc617dddb5d3c2b7e839550c19936592 100644
--- a/chrome/browser/ui/tabs/tab_strip_model_unittest.cc
+++ b/chrome/browser/ui/tabs/tab_strip_model_unittest.cc
@@ -31,6 +31,7 @@
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "chrome/test/base/testing_profile.h"
#include "components/web_modal/web_contents_modal_dialog_manager.h"
+#include "components/zoom/zoom_controller.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/render_process_host.h"
@@ -38,6 +39,7 @@
#include "content/public/browser/web_contents_observer.h"
#include "content/public/test/web_contents_tester.h"
#include "extensions/common/extension.h"
+#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
using content::SiteInstance;
@@ -2124,6 +2126,42 @@ TEST_F(TabStripModelTest, ReplaceSendsSelected) {
strip.CloseAllTabs();
}
+namespace {
+class MockZoomController : public zoom::ZoomController {
+ public:
+ static void CreateForTesting(content::WebContents* contents) {
+ ASSERT_FALSE(zoom::ZoomController::FromWebContents(contents));
+ contents->SetUserData(UserDataKey(), new MockZoomController(contents));
+ }
+
+ explicit MockZoomController(content::WebContents* contents)
+ : zoom::ZoomController(contents) {}
+
+ MOCK_METHOD1(WebContentsReplaced, void(WebContents* new_contents));
+};
+} // namespace
+
+// Makes sure the TabStripModel notifies the ZoomController during the
+// replacement of its WebContents.
+TEST_F(TabStripModelTest, ReplaceNotifiesZoomController) {
+ TabStripDummyDelegate delegate;
+ TabStripModel strip(&delegate, profile());
+
+ WebContents* contents1 = CreateWebContents();
+ WebContents* contents2 = CreateWebContents();
+ MockZoomController::CreateForTesting(contents1);
+ MockZoomController* mock_controller = static_cast<MockZoomController*>(
+ zoom::ZoomController::FromWebContents(contents1));
+ ASSERT_TRUE(mock_controller);
+
+ strip.AppendWebContents(contents1, true);
+
+ EXPECT_CALL(*mock_controller, WebContentsReplaced(contents2));
+ delete strip.ReplaceWebContentsAt(0, contents2);
+
+ strip.CloseAllTabs();
+}
+
// Makes sure TabStripModel handles the case of deleting a tab while removing
// another tab.
TEST_F(TabStripModelTest, DeleteFromDestroy) {
« no previous file with comments | « chrome/browser/ui/tabs/tab_strip_model.cc ('k') | chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698