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

Side by Side Diff: chrome/browser/ui/webui/prefs_internals_browsertest.cc

Issue 2725903002: [WebUI] Add a chrome://prefs-internals page (Closed)
Patch Set: Dan's Created 3 years, 9 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 | « chrome/browser/ui/BUILD.gn ('k') | chrome/browser/ui/webui/prefs_internals_source.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/guid.h"
6 #include "base/strings/stringprintf.h"
7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/tabs/tab_strip_model.h"
10 #include "chrome/common/pref_names.h"
11 #include "chrome/test/base/in_process_browser_test.h"
12 #include "chrome/test/base/ui_test_utils.h"
13 #include "components/prefs/pref_service.h"
14 #include "content/public/browser/web_contents.h"
15 #include "content/public/test/browser_test_utils.h"
16 #include "url/gurl.h"
17
18 using PrefsInternalsTest = InProcessBrowserTest;
19
20 IN_PROC_BROWSER_TEST_F(PrefsInternalsTest, TestPrefsAreServed) {
21 // Set a preference to something very unique so we can look for it in the
22 // generated page.
23 std::string guid = base::GenerateGUID();
24 GURL fake_homepage_url = GURL("http://example.com/" + guid);
25 EXPECT_TRUE(fake_homepage_url.is_valid());
26 browser()->profile()->GetPrefs()->SetString(prefs::kHomePage,
27 fake_homepage_url.spec());
28
29 // First, check that navigation succeeds.
30 GURL kUrl("chrome://prefs-internals");
31 ui_test_utils::NavigateToURL(browser(), kUrl);
32 content::WebContents* web_contents =
33 browser()->tab_strip_model()->GetActiveWebContents();
34 ASSERT_TRUE(web_contents);
35 EXPECT_EQ(kUrl, web_contents->GetLastCommittedURL());
36 EXPECT_FALSE(web_contents->IsCrashed());
37 EXPECT_FALSE(web_contents->GetInterstitialPage());
38
39 // It's difficult to test the content of the page without duplicating the
40 // implementation, but we can at least assert that something is being shown.
41 bool has_text = false;
42 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
43 web_contents,
44 base::StringPrintf("window.domAutomationController.send("
45 "document.body.textContent && "
46 "document.body.textContent.indexOf('%s') >= 0);",
47 guid.c_str()),
48 &has_text));
49 EXPECT_TRUE(has_text);
50 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/BUILD.gn ('k') | chrome/browser/ui/webui/prefs_internals_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698