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

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

Issue 2931243002: Unframe chrome://extensions as it's the last (and only) uber item (Closed)
Patch Set: policy_android.css Created 3 years, 6 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/webui/help/help_ui.cc ('k') | chrome/browser/ui/webui/policy_ui.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/webui/log_web_ui_url.h" 5 #include "chrome/browser/ui/webui/log_web_ui_url.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/hash.h" 11 #include "base/hash.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/test/histogram_tester.h" 13 #include "base/test/histogram_tester.h"
14 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_commands.h" 15 #include "chrome/browser/ui/browser_commands.h"
16 #include "chrome/browser/ui/tabs/tab_strip_model.h" 16 #include "chrome/browser/ui/tabs/tab_strip_model.h"
17 #include "chrome/common/url_constants.h" 17 #include "chrome/common/url_constants.h"
18 #include "chrome/grit/generated_resources.h" 18 #include "chrome/grit/generated_resources.h"
19 #include "chrome/test/base/in_process_browser_test.h" 19 #include "chrome/test/base/in_process_browser_test.h"
20 #include "chrome/test/base/ui_test_utils.h" 20 #include "chrome/test/base/ui_test_utils.h"
21 #include "components/strings/grit/components_strings.h"
21 #include "content/public/common/url_constants.h" 22 #include "content/public/common/url_constants.h"
22 #include "content/public/test/browser_test_utils.h" 23 #include "content/public/test/browser_test_utils.h"
23 #include "extensions/features/features.h"
24 #include "testing/gmock/include/gmock/gmock.h" 24 #include "testing/gmock/include/gmock/gmock.h"
25 #include "ui/base/l10n/l10n_util.h" 25 #include "ui/base/l10n/l10n_util.h"
26 #include "url/gurl.h" 26 #include "url/gurl.h"
27 27
28 using base::Bucket; 28 using base::Bucket;
29 using testing::ElementsAre; 29 using testing::ElementsAre;
30 30
31 namespace webui { 31 namespace webui {
32 32
33 class LogWebUIUrlTest : public InProcessBrowserTest { 33 class LogWebUIUrlTest : public InProcessBrowserTest {
34 public: 34 public:
35 LogWebUIUrlTest() {} 35 LogWebUIUrlTest() {}
36 ~LogWebUIUrlTest() override {} 36 ~LogWebUIUrlTest() override {}
37 37
38 std::vector<Bucket> GetSamples() { 38 void RunTest(int title_ids, const GURL& url) {
39 return histogram_tester_.GetAllSamples(webui::kWebUICreatedForUrl); 39 auto* tab = browser()->tab_strip_model()->GetActiveWebContents();
40 base::string16 title = l10n_util::GetStringUTF16(title_ids);
41 content::TitleWatcher title_watcher(tab, title);
42 ui_test_utils::NavigateToURL(browser(), url);
43 ASSERT_EQ(title, title_watcher.WaitAndGetTitle());
44 uint32_t origin_hash = base::Hash(url.GetOrigin().spec());
45 EXPECT_THAT(histogram_tester_.GetAllSamples(webui::kWebUICreatedForUrl),
46 ElementsAre(Bucket(origin_hash, 1)));
40 } 47 }
41 48
42 private: 49 private:
43 base::HistogramTester histogram_tester_; 50 base::HistogramTester histogram_tester_;
44 51
45 DISALLOW_COPY_AND_ASSIGN(LogWebUIUrlTest); 52 DISALLOW_COPY_AND_ASSIGN(LogWebUIUrlTest);
46 }; 53 };
47 54
48 #if BUILDFLAG(ENABLE_EXTENSIONS)
49 IN_PROC_BROWSER_TEST_F(LogWebUIUrlTest, TestExtensionsPage) { 55 IN_PROC_BROWSER_TEST_F(LogWebUIUrlTest, TestExtensionsPage) {
50 content::WebContents* tab = 56 RunTest(IDS_MANAGE_EXTENSIONS_SETTING_WINDOWS_TITLE,
51 browser()->tab_strip_model()->GetActiveWebContents(); 57 GURL(chrome::kChromeUIExtensionsURL));
58 }
52 59
53 base::string16 extension_title = 60 IN_PROC_BROWSER_TEST_F(LogWebUIUrlTest, TestHistoryPage) {
54 l10n_util::GetStringUTF16(IDS_MANAGE_EXTENSIONS_SETTING_WINDOWS_TITLE); 61 RunTest(IDS_HISTORY_TITLE, GURL(chrome::kChromeUIHistoryURL));
62 }
55 63
56 { 64 IN_PROC_BROWSER_TEST_F(LogWebUIUrlTest, TestSettingsPage) {
57 content::TitleWatcher title_watcher(tab, extension_title); 65 RunTest(IDS_SETTINGS_SETTINGS, GURL(chrome::kChromeUISettingsURL));
58 ui_test_utils::NavigateToURL(browser(),
59 GURL(chrome::kChromeUIExtensionsURL));
60 ASSERT_EQ(extension_title, title_watcher.WaitAndGetTitle());
61 }
62
63 std::string scheme(content::kChromeUIScheme);
64 GURL uber_url(scheme + "://" + chrome::kChromeUIUberHost);
65 uint32_t uber_url_hash = base::Hash(uber_url.spec());
66
67 GURL uber_frame_url(chrome::kChromeUIUberFrameURL);
68 uint32_t uber_frame_url_hash = base::Hash(uber_frame_url.spec());
69
70 GURL extensions_frame_url(chrome::kChromeUIExtensionsFrameURL);
71 uint32_t extensions_frame_url_hash = base::Hash(extensions_frame_url.spec());
72
73 EXPECT_THAT(GetSamples(), ElementsAre(Bucket(extensions_frame_url_hash, 1),
74 Bucket(uber_frame_url_hash, 1),
75 Bucket(uber_url_hash, 1)));
76 } 66 }
77 #endif
78 67
79 } // namespace webui 68 } // namespace webui
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/help/help_ui.cc ('k') | chrome/browser/ui/webui/policy_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698