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

Side by Side 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 unified diff | Download patch
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 "chrome/browser/ui/tabs/tab_strip_model.h" 5 #include "chrome/browser/ui/tabs/tab_strip_model.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
(...skipping 13 matching lines...) Expand all
24 #include "chrome/browser/ui/browser.h" 24 #include "chrome/browser/ui/browser.h"
25 #include "chrome/browser/ui/browser_tabstrip.h" 25 #include "chrome/browser/ui/browser_tabstrip.h"
26 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" 26 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h"
27 #include "chrome/browser/ui/tabs/tab_strip_model_order_controller.h" 27 #include "chrome/browser/ui/tabs/tab_strip_model_order_controller.h"
28 #include "chrome/browser/ui/tabs/test_tab_strip_model_delegate.h" 28 #include "chrome/browser/ui/tabs/test_tab_strip_model_delegate.h"
29 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" 29 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
30 #include "chrome/common/url_constants.h" 30 #include "chrome/common/url_constants.h"
31 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 31 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
32 #include "chrome/test/base/testing_profile.h" 32 #include "chrome/test/base/testing_profile.h"
33 #include "components/web_modal/web_contents_modal_dialog_manager.h" 33 #include "components/web_modal/web_contents_modal_dialog_manager.h"
34 #include "components/zoom/zoom_controller.h"
34 #include "content/public/browser/navigation_controller.h" 35 #include "content/public/browser/navigation_controller.h"
35 #include "content/public/browser/navigation_entry.h" 36 #include "content/public/browser/navigation_entry.h"
36 #include "content/public/browser/render_process_host.h" 37 #include "content/public/browser/render_process_host.h"
37 #include "content/public/browser/web_contents.h" 38 #include "content/public/browser/web_contents.h"
38 #include "content/public/browser/web_contents_observer.h" 39 #include "content/public/browser/web_contents_observer.h"
39 #include "content/public/test/web_contents_tester.h" 40 #include "content/public/test/web_contents_tester.h"
40 #include "extensions/common/extension.h" 41 #include "extensions/common/extension.h"
42 #include "testing/gmock/include/gmock/gmock.h"
41 #include "testing/gtest/include/gtest/gtest.h" 43 #include "testing/gtest/include/gtest/gtest.h"
42 44
43 using content::SiteInstance; 45 using content::SiteInstance;
44 using content::WebContents; 46 using content::WebContents;
45 using content::WebContentsTester; 47 using content::WebContentsTester;
46 using extensions::Extension; 48 using extensions::Extension;
47 49
48 namespace { 50 namespace {
49 51
50 // Class used to delete a WebContents and TabStripModel when another WebContents 52 // Class used to delete a WebContents and TabStripModel when another WebContents
(...skipping 2066 matching lines...) Expand 10 before | Expand all | Expand 10 after
2117 2119
2118 ASSERT_EQ(1, tabstrip_observer.GetStateCount()); 2120 ASSERT_EQ(1, tabstrip_observer.GetStateCount());
2119 2121
2120 state = State(new_contents, 1, MockTabStripModelObserver::REPLACED); 2122 state = State(new_contents, 1, MockTabStripModelObserver::REPLACED);
2121 state.src_contents = third_contents; 2123 state.src_contents = third_contents;
2122 EXPECT_TRUE(tabstrip_observer.StateEquals(0, state)); 2124 EXPECT_TRUE(tabstrip_observer.StateEquals(0, state));
2123 2125
2124 strip.CloseAllTabs(); 2126 strip.CloseAllTabs();
2125 } 2127 }
2126 2128
2129 namespace {
2130 class MockZoomController : public zoom::ZoomController {
2131 public:
2132 static void CreateForTesting(content::WebContents* contents) {
2133 ASSERT_FALSE(zoom::ZoomController::FromWebContents(contents));
2134 contents->SetUserData(UserDataKey(), new MockZoomController(contents));
2135 }
2136
2137 explicit MockZoomController(content::WebContents* contents)
2138 : zoom::ZoomController(contents) {}
2139
2140 MOCK_METHOD1(WebContentsReplaced, void(WebContents* new_contents));
2141 };
2142 } // namespace
2143
2144 // Makes sure the TabStripModel notifies the ZoomController during the
2145 // replacement of its WebContents.
2146 TEST_F(TabStripModelTest, ReplaceNotifiesZoomController) {
2147 TabStripDummyDelegate delegate;
2148 TabStripModel strip(&delegate, profile());
2149
2150 WebContents* contents1 = CreateWebContents();
2151 WebContents* contents2 = CreateWebContents();
2152 MockZoomController::CreateForTesting(contents1);
2153 MockZoomController* mock_controller = static_cast<MockZoomController*>(
2154 zoom::ZoomController::FromWebContents(contents1));
2155 ASSERT_TRUE(mock_controller);
2156
2157 strip.AppendWebContents(contents1, true);
2158
2159 EXPECT_CALL(*mock_controller, WebContentsReplaced(contents2));
2160 delete strip.ReplaceWebContentsAt(0, contents2);
2161
2162 strip.CloseAllTabs();
2163 }
2164
2127 // Makes sure TabStripModel handles the case of deleting a tab while removing 2165 // Makes sure TabStripModel handles the case of deleting a tab while removing
2128 // another tab. 2166 // another tab.
2129 TEST_F(TabStripModelTest, DeleteFromDestroy) { 2167 TEST_F(TabStripModelTest, DeleteFromDestroy) {
2130 TabStripDummyDelegate delegate; 2168 TabStripDummyDelegate delegate;
2131 TabStripModel strip(&delegate, profile()); 2169 TabStripModel strip(&delegate, profile());
2132 WebContents* contents1 = CreateWebContents(); 2170 WebContents* contents1 = CreateWebContents();
2133 WebContents* contents2 = CreateWebContents(); 2171 WebContents* contents2 = CreateWebContents();
2134 MockTabStripModelObserver tab_strip_model_observer(&strip); 2172 MockTabStripModelObserver tab_strip_model_observer(&strip);
2135 strip.AppendWebContents(contents1, true); 2173 strip.AppendWebContents(contents1, true);
2136 strip.AppendWebContents(contents2, true); 2174 strip.AppendWebContents(contents2, true);
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
2544 strip.AddObserver(&observer); 2582 strip.AddObserver(&observer);
2545 2583
2546 strip.ActivateTabAt(1, true); 2584 strip.ActivateTabAt(1, true);
2547 EXPECT_EQ(1, strip.active_index()); 2585 EXPECT_EQ(1, strip.active_index());
2548 2586
2549 strip.MoveWebContentsAt(2, 3, true); 2587 strip.MoveWebContentsAt(2, 3, true);
2550 EXPECT_EQ(3, strip.active_index()); 2588 EXPECT_EQ(3, strip.active_index());
2551 2589
2552 strip.CloseAllTabs(); 2590 strip.CloseAllTabs();
2553 } 2591 }
OLDNEW
« 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