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

Side by Side Diff: chrome/browser/extensions/api/tabs/tabs_test.cc

Issue 1409163006: Migrating tests to use EmbeddedTestServer (/chrome/browser misc) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 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 5
6 #include <string> 6 #include <string>
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 24 matching lines...) Expand all
35 #include "content/public/common/page_zoom.h" 35 #include "content/public/common/page_zoom.h"
36 #include "content/public/common/url_constants.h" 36 #include "content/public/common/url_constants.h"
37 #include "extensions/browser/api_test_utils.h" 37 #include "extensions/browser/api_test_utils.h"
38 #include "extensions/browser/app_window/app_window.h" 38 #include "extensions/browser/app_window/app_window.h"
39 #include "extensions/browser/app_window/app_window_registry.h" 39 #include "extensions/browser/app_window/app_window_registry.h"
40 #include "extensions/browser/app_window/native_app_window.h" 40 #include "extensions/browser/app_window/native_app_window.h"
41 #include "extensions/common/manifest_constants.h" 41 #include "extensions/common/manifest_constants.h"
42 #include "extensions/common/test_util.h" 42 #include "extensions/common/test_util.h"
43 #include "extensions/test/extension_test_message_listener.h" 43 #include "extensions/test/extension_test_message_listener.h"
44 #include "extensions/test/result_catcher.h" 44 #include "extensions/test/result_catcher.h"
45 #include "net/test/spawned_test_server/spawned_test_server.h" 45 #include "net/test/embedded_test_server/embedded_test_server.h"
46 #include "ui/gfx/geometry/rect.h" 46 #include "ui/gfx/geometry/rect.h"
47 #include "ui/views/widget/widget.h" 47 #include "ui/views/widget/widget.h"
48 #include "ui/views/widget/widget_observer.h" 48 #include "ui/views/widget/widget_observer.h"
49 49
50 #if defined(OS_MACOSX) 50 #if defined(OS_MACOSX)
51 #include "base/mac/mac_util.h" 51 #include "base/mac/mac_util.h"
52 #include "ui/base/test/scoped_fake_nswindow_fullscreen.h" 52 #include "ui/base/test/scoped_fake_nswindow_fullscreen.h"
53 #endif 53 #endif
54 54
55 namespace extensions { 55 namespace extensions {
(...skipping 1545 matching lines...) Expand 10 before | Expand all | Expand 10 after
1601 EXPECT_TRUE(content::ZoomValuesEqual( 1601 EXPECT_TRUE(content::ZoomValuesEqual(
1602 new_default_zoom_level, 1602 new_default_zoom_level,
1603 content::ZoomFactorToZoomLevel(observed_zoom_factor))); 1603 content::ZoomFactorToZoomLevel(observed_zoom_factor)));
1604 } 1604 }
1605 1605
1606 IN_PROC_BROWSER_TEST_F(ExtensionTabsZoomTest, ZoomSettings) { 1606 IN_PROC_BROWSER_TEST_F(ExtensionTabsZoomTest, ZoomSettings) {
1607 // In this test we need two URLs that (1) represent real pages (i.e. they 1607 // In this test we need two URLs that (1) represent real pages (i.e. they
1608 // load without causing an error page load), (2) have different domains, and 1608 // load without causing an error page load), (2) have different domains, and
1609 // (3) are zoomable by the extension API (this last condition rules out 1609 // (3) are zoomable by the extension API (this last condition rules out
1610 // chrome:// urls). We achieve this by noting that about:blank meets these 1610 // chrome:// urls). We achieve this by noting that about:blank meets these
1611 // requirements, allowing us to spin up a spawned http server on localhost to 1611 // requirements, allowing us to spin up an embedded http server on localhost
1612 // get the other domain. 1612 // to get the other domain.
1613 net::SpawnedTestServer http_server( 1613 net::EmbeddedTestServer http_server;
1614 net::SpawnedTestServer::TYPE_HTTP, 1614 http_server.ServeFilesFromSourceDirectory("chrome/test/data");
1615 net::SpawnedTestServer::kLocalhost,
1616 base::FilePath(FILE_PATH_LITERAL("chrome/test/data")));
1617 ASSERT_TRUE(http_server.Start()); 1615 ASSERT_TRUE(http_server.Start());
1618 1616
1619 GURL url_A = http_server.GetURL("files/simple.html"); 1617 GURL url_A = http_server.GetURL("/simple.html");
1620 GURL url_B("about:blank"); 1618 GURL url_B("about:blank");
1621 1619
1622 // Tabs A1 and A2 are navigated to the same origin, while B is navigated 1620 // Tabs A1 and A2 are navigated to the same origin, while B is navigated
1623 // to a different one. 1621 // to a different one.
1624 content::WebContents* web_contents_A1 = OpenUrlAndWaitForLoad(url_A); 1622 content::WebContents* web_contents_A1 = OpenUrlAndWaitForLoad(url_A);
1625 content::WebContents* web_contents_A2 = OpenUrlAndWaitForLoad(url_A); 1623 content::WebContents* web_contents_A2 = OpenUrlAndWaitForLoad(url_A);
1626 content::WebContents* web_contents_B = OpenUrlAndWaitForLoad(url_B); 1624 content::WebContents* web_contents_B = OpenUrlAndWaitForLoad(url_B);
1627 1625
1628 int tab_id_A1 = ExtensionTabUtil::GetTabId(web_contents_A1); 1626 int tab_id_A1 = ExtensionTabUtil::GetTabId(web_contents_A1);
1629 int tab_id_A2 = ExtensionTabUtil::GetTabId(web_contents_A2); 1627 int tab_id_A2 = ExtensionTabUtil::GetTabId(web_contents_A2);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1668 EXPECT_TRUE(base::MatchPattern(error, keys::kCannotZoomDisabledTabError)); 1666 EXPECT_TRUE(base::MatchPattern(error, keys::kCannotZoomDisabledTabError));
1669 EXPECT_FLOAT_EQ( 1667 EXPECT_FLOAT_EQ(
1670 1.f, content::ZoomLevelToZoomFactor(GetZoomLevel(web_contents_A1))); 1668 1.f, content::ZoomLevelToZoomFactor(GetZoomLevel(web_contents_A1)));
1671 // We should still be able to zoom A2 though. 1669 // We should still be able to zoom A2 though.
1672 EXPECT_TRUE(RunSetZoom(tab_id_A2, 1.4f)); 1670 EXPECT_TRUE(RunSetZoom(tab_id_A2, 1.4f));
1673 EXPECT_FLOAT_EQ( 1671 EXPECT_FLOAT_EQ(
1674 1.4f, content::ZoomLevelToZoomFactor(GetZoomLevel(web_contents_A2))); 1672 1.4f, content::ZoomLevelToZoomFactor(GetZoomLevel(web_contents_A2)));
1675 } 1673 }
1676 1674
1677 IN_PROC_BROWSER_TEST_F(ExtensionTabsZoomTest, PerTabResetsOnNavigation) { 1675 IN_PROC_BROWSER_TEST_F(ExtensionTabsZoomTest, PerTabResetsOnNavigation) {
1678 net::SpawnedTestServer http_server( 1676 net::EmbeddedTestServer http_server;
1679 net::SpawnedTestServer::TYPE_HTTP, 1677 http_server.ServeFilesFromSourceDirectory("chrome/test/data");
1680 net::SpawnedTestServer::kLocalhost,
1681 base::FilePath(FILE_PATH_LITERAL("chrome/test/data")));
1682 ASSERT_TRUE(http_server.Start()); 1678 ASSERT_TRUE(http_server.Start());
1683 1679
1684 GURL url_A = http_server.GetURL("files/simple.html"); 1680 GURL url_A = http_server.GetURL("/simple.html");
1685 GURL url_B("about:blank"); 1681 GURL url_B("about:blank");
1686 1682
1687 content::WebContents* web_contents = OpenUrlAndWaitForLoad(url_A); 1683 content::WebContents* web_contents = OpenUrlAndWaitForLoad(url_A);
1688 int tab_id = ExtensionTabUtil::GetTabId(web_contents); 1684 int tab_id = ExtensionTabUtil::GetTabId(web_contents);
1689 EXPECT_TRUE(RunSetZoomSettings(tab_id, "automatic", "per-tab")); 1685 EXPECT_TRUE(RunSetZoomSettings(tab_id, "automatic", "per-tab"));
1690 1686
1691 std::string mode; 1687 std::string mode;
1692 std::string scope; 1688 std::string scope;
1693 EXPECT_TRUE(RunGetZoomSettings(tab_id, &mode, &scope)); 1689 EXPECT_TRUE(RunGetZoomSettings(tab_id, &mode, &scope));
1694 EXPECT_EQ("automatic", mode); 1690 EXPECT_EQ("automatic", mode);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1750 EXPECT_TRUE( 1746 EXPECT_TRUE(
1751 base::MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); 1747 base::MatchPattern(error, manifest_errors::kCannotAccessChromeUrl));
1752 1748
1753 // chrome.tabs.setZoomSettings(). 1749 // chrome.tabs.setZoomSettings().
1754 error = RunSetZoomSettingsExpectError(tab_id, "manual", "per-tab"); 1750 error = RunSetZoomSettingsExpectError(tab_id, "manual", "per-tab");
1755 EXPECT_TRUE( 1751 EXPECT_TRUE(
1756 base::MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); 1752 base::MatchPattern(error, manifest_errors::kCannotAccessChromeUrl));
1757 } 1753 }
1758 1754
1759 } // namespace extensions 1755 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698