OLD | NEW |
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/browser/ui/webui/md_history_ui.h" |
17 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
18 #include "chrome/test/base/in_process_browser_test.h" | 19 #include "chrome/test/base/in_process_browser_test.h" |
19 #include "chrome/test/base/ui_test_utils.h" | 20 #include "chrome/test/base/ui_test_utils.h" |
20 #include "content/public/common/url_constants.h" | 21 #include "content/public/common/url_constants.h" |
21 #include "content/public/test/browser_test_utils.h" | 22 #include "content/public/test/browser_test_utils.h" |
22 #include "grit/components_strings.h" | 23 #include "grit/components_strings.h" |
23 #include "grit/generated_resources.h" | 24 #include "grit/generated_resources.h" |
24 #include "testing/gmock/include/gmock/gmock.h" | 25 #include "testing/gmock/include/gmock/gmock.h" |
25 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
26 #include "url/gurl.h" | 27 #include "url/gurl.h" |
27 | 28 |
28 using base::Bucket; | 29 using base::Bucket; |
29 using testing::ElementsAre; | 30 using testing::ElementsAre; |
30 | 31 |
31 namespace webui { | 32 namespace webui { |
32 | 33 |
33 class LogWebUIUrlTest : public InProcessBrowserTest { | 34 class LogWebUIUrlTest : public InProcessBrowserTest { |
34 public: | 35 public: |
35 LogWebUIUrlTest() {} | 36 LogWebUIUrlTest() {} |
36 ~LogWebUIUrlTest() override {} | 37 ~LogWebUIUrlTest() override {} |
37 | 38 |
38 std::vector<Bucket> GetSamples() { | 39 std::vector<Bucket> GetSamples() { |
39 return histogram_tester_.GetAllSamples(webui::kWebUICreatedForUrl); | 40 return histogram_tester_.GetAllSamples(webui::kWebUICreatedForUrl); |
40 } | 41 } |
41 | 42 |
| 43 void SetUpOnMainThread() override { |
| 44 // Disable MD History to test non-MD history page. |
| 45 MdHistoryUI::DisableForTesting(); |
| 46 } |
| 47 |
42 private: | 48 private: |
43 base::HistogramTester histogram_tester_; | 49 base::HistogramTester histogram_tester_; |
44 | 50 |
45 DISALLOW_COPY_AND_ASSIGN(LogWebUIUrlTest); | 51 DISALLOW_COPY_AND_ASSIGN(LogWebUIUrlTest); |
46 }; | 52 }; |
47 | 53 |
48 IN_PROC_BROWSER_TEST_F(LogWebUIUrlTest, TestHistoryFrame) { | 54 IN_PROC_BROWSER_TEST_F(LogWebUIUrlTest, TestHistoryFrame) { |
49 GURL history_frame_url(chrome::kChromeUIHistoryFrameURL); | 55 GURL history_frame_url(chrome::kChromeUIHistoryFrameURL); |
50 | 56 |
51 ui_test_utils::NavigateToURL(browser(), history_frame_url); | 57 ui_test_utils::NavigateToURL(browser(), history_frame_url); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 uint32_t extensions_frame_url_hash = base::Hash(extensions_frame_url.spec()); | 116 uint32_t extensions_frame_url_hash = base::Hash(extensions_frame_url.spec()); |
111 | 117 |
112 EXPECT_THAT(GetSamples(), ElementsAre(Bucket(extensions_frame_url_hash, 1), | 118 EXPECT_THAT(GetSamples(), ElementsAre(Bucket(extensions_frame_url_hash, 1), |
113 Bucket(history_frame_url_hash, 2), | 119 Bucket(history_frame_url_hash, 2), |
114 Bucket(uber_frame_url_hash, 2), | 120 Bucket(uber_frame_url_hash, 2), |
115 Bucket(uber_url_hash, 2))); | 121 Bucket(uber_url_hash, 2))); |
116 } | 122 } |
117 #endif | 123 #endif |
118 | 124 |
119 } // namespace webui | 125 } // namespace webui |
OLD | NEW |