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

Side by Side Diff: chrome/browser/browser_commands_unittest.cc

Issue 678343002: Default zoom was never read from chrome://settings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replaced header in testing_profile Created 6 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
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/app/chrome_command_ids.h" 5 #include "chrome/app/chrome_command_ids.h"
6 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 6 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
7 #include "chrome/browser/chrome_page_zoom.h" 7 #include "chrome/browser/chrome_page_zoom.h"
8 #include "chrome/browser/ui/browser_command_controller.h" 8 #include "chrome/browser/ui/browser_command_controller.h"
9 #include "chrome/browser/ui/browser_commands.h" 9 #include "chrome/browser/ui/browser_commands.h"
10 #include "chrome/browser/ui/browser_finder.h" 10 #include "chrome/browser/ui/browser_finder.h"
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" 11 #include "chrome/browser/ui/tabs/tab_strip_model.h"
12 #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h"
12 #include "chrome/browser/ui/zoom/zoom_controller.h" 13 #include "chrome/browser/ui/zoom/zoom_controller.h"
13 #include "chrome/common/url_constants.h" 14 #include "chrome/common/url_constants.h"
14 #include "chrome/test/base/browser_with_test_window_test.h" 15 #include "chrome/test/base/browser_with_test_window_test.h"
15 #include "chrome/test/base/testing_profile.h" 16 #include "chrome/test/base/testing_profile.h"
16 #include "components/bookmarks/browser/bookmark_model.h" 17 #include "components/bookmarks/browser/bookmark_model.h"
17 #include "components/bookmarks/test/bookmark_test_helpers.h" 18 #include "components/bookmarks/test/bookmark_test_helpers.h"
18 #include "content/public/browser/navigation_controller.h" 19 #include "content/public/browser/navigation_controller.h"
19 #include "content/public/browser/navigation_entry.h" 20 #include "content/public/browser/navigation_entry.h"
20 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
21 22
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 tab_strip_model->ActivateTabAt(1, true); 333 tab_strip_model->ActivateTabAt(1, true);
333 EXPECT_TRUE(tab_strip_model->IsTabSelected(1)); 334 EXPECT_TRUE(tab_strip_model->IsTabSelected(1));
334 chrome_page_zoom::Zoom(contents2, content::PAGE_ZOOM_OUT); 335 chrome_page_zoom::Zoom(contents2, content::PAGE_ZOOM_OUT);
335 336
336 zoom_controller = ZoomController::FromWebContents(contents2); 337 zoom_controller = ZoomController::FromWebContents(contents2);
337 EXPECT_EQ(zoom_controller->GetZoomPercent(), 90.0f); 338 EXPECT_EQ(zoom_controller->GetZoomPercent(), 90.0f);
338 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_PLUS)); 339 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_PLUS));
339 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_NORMAL)); 340 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_NORMAL));
340 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_MINUS)); 341 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_MINUS));
341 } 342 }
343
344 TEST_F(BrowserCommandsTest, OnDefaultZoomLevelChanged) {
345 TabStripModel* tab_strip_model = browser()->tab_strip_model();
346 GURL url("http://code.google.com");
347 AddTab(browser(), url);
348 content::WebContents* contents = tab_strip_model->GetWebContentsAt(0);
349 ZoomController* zoom_controller = ZoomController::FromWebContents(contents);
350
351 // Set the default zoom level to 125.
352 profile()->GetZoomLevelPrefs()->SetDefaultZoomLevelPref(
353 content::ZoomFactorToZoomLevel(1.25));
354 EXPECT_EQ(zoom_controller->GetZoomPercent(), 125);
sky 2014/11/24 15:46:57 Format for assertions in tests is 'expected, actua
355
356 // Actual Size from context menu should be disabled now.
357 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_PLUS));
358 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_NORMAL));
359 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_MINUS));
360
361 // Change the zoom level.
362 chrome_page_zoom::Zoom(contents, content::PAGE_ZOOM_IN);
363
364 EXPECT_EQ(zoom_controller->GetZoomPercent(), 150);
365
366 // Tab no longer at default zoom hence Actual size should be enabled.
367 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_PLUS));
368 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_NORMAL));
369 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_MINUS));
370 }
371
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/browser_command_controller.cc » ('j') | chrome/browser/ui/browser_commands.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698