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

Side by Side Diff: chrome/browser/download/save_page_browsertest.cc

Issue 2854693002: Remove a host_resolver()->ClearRules call in a test body and replace it with an AddRule call that h… (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 void SetUpCommandLine(base::CommandLine* command_line) override { 873 void SetUpCommandLine(base::CommandLine* command_line) override {
874 SavePageBrowserTest::SetUpCommandLine(command_line); 874 SavePageBrowserTest::SetUpCommandLine(command_line);
875 875
876 // Append --site-per-process flag. 876 // Append --site-per-process flag.
877 content::IsolateAllSitesForTesting(command_line); 877 content::IsolateAllSitesForTesting(command_line);
878 } 878 }
879 879
880 void SetUpOnMainThread() override { 880 void SetUpOnMainThread() override {
881 SavePageBrowserTest::SetUpOnMainThread(); 881 SavePageBrowserTest::SetUpOnMainThread();
882 882
883 // Used by the BrokenImage test which depends on *.no.such.host not
884 // resolving to 127.0.0.1
885 host_resolver()->AddRule("no.such.host", "128.0.0.1");
883 host_resolver()->AddRule("*", "127.0.0.1"); 886 host_resolver()->AddRule("*", "127.0.0.1");
884 ASSERT_TRUE(embedded_test_server()->InitializeAndListen()); 887 ASSERT_TRUE(embedded_test_server()->InitializeAndListen());
885 content::SetupCrossSiteRedirector(embedded_test_server()); 888 content::SetupCrossSiteRedirector(embedded_test_server());
886 embedded_test_server()->StartAcceptingConnections(); 889 embedded_test_server()->StartAcceptingConnections();
887 } 890 }
888 891
889 private: 892 private:
890 DISALLOW_COPY_AND_ASSIGN(SavePageSitePerProcessBrowserTest); 893 DISALLOW_COPY_AND_ASSIGN(SavePageSitePerProcessBrowserTest);
891 }; 894 };
892 895
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
1324 1327
1325 // The original page has 7 iframes. One of them that contains hidden attribute 1328 // The original page has 7 iframes. One of them that contains hidden attribute
1326 // will be excluded from the saved page. 1329 // will be excluded from the saved page.
1327 TestOriginalVsSavedPage(save_page_type, url, 7, 6, expected_substrings); 1330 TestOriginalVsSavedPage(save_page_type, url, 7, 6, expected_substrings);
1328 } 1331 }
1329 1332
1330 // Test for saving a page with broken subresources: 1333 // Test for saving a page with broken subresources:
1331 // - Broken, undecodable image (see also https://crbug.com/586680) 1334 // - Broken, undecodable image (see also https://crbug.com/586680)
1332 // - Broken link, to unresolvable host (see also https://crbug.com/594219) 1335 // - Broken link, to unresolvable host (see also https://crbug.com/594219)
1333 IN_PROC_BROWSER_TEST_P(SavePageOriginalVsSavedComparisonTest, BrokenImage) { 1336 IN_PROC_BROWSER_TEST_P(SavePageOriginalVsSavedComparisonTest, BrokenImage) {
1334 // Clear resolver rules to make sure that *.no.such.host used in the test html
1335 // doesn't resolve to 127.0.0.1
1336 host_resolver()->ClearRules();
1337
1338 content::SavePageType save_page_type = GetParam(); 1337 content::SavePageType save_page_type = GetParam();
1339 1338
1340 std::string arr[] = { 1339 std::string arr[] = {
1341 "broken-image.htm: 1e846775-b3ed-4d9c-a124-029554a1eb9d", 1340 "broken-image.htm: 1e846775-b3ed-4d9c-a124-029554a1eb9d",
1342 }; 1341 };
1343 std::vector<std::string> expected_substrings(std::begin(arr), std::end(arr)); 1342 std::vector<std::string> expected_substrings(std::begin(arr), std::end(arr));
1344 1343
1345 GURL url(embedded_test_server()->GetURL("127.0.0.1", 1344 GURL url(embedded_test_server()->GetURL("127.0.0.1",
1346 "/save_page/broken-image.htm")); 1345 "/save_page/broken-image.htm"));
1347 1346
1348 TestOriginalVsSavedPage(save_page_type, url, 1, 1, expected_substrings); 1347 TestOriginalVsSavedPage(save_page_type, url, 1, 1, expected_substrings);
1349 } 1348 }
1350 1349
1351 INSTANTIATE_TEST_CASE_P( 1350 INSTANTIATE_TEST_CASE_P(
1352 SaveType, 1351 SaveType,
1353 SavePageOriginalVsSavedComparisonTest, 1352 SavePageOriginalVsSavedComparisonTest,
1354 ::testing::Values(content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, 1353 ::testing::Values(content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML,
1355 content::SAVE_PAGE_TYPE_AS_MHTML)); 1354 content::SAVE_PAGE_TYPE_AS_MHTML));
1356 1355
1357 } // namespace 1356 } // namespace
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698