| 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/feature_list.h" |
| 11 #include "base/hash.h" | 12 #include "base/hash.h" |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/test/histogram_tester.h" | 14 #include "base/test/histogram_tester.h" |
| 14 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/browser_commands.h" | 16 #include "chrome/browser/ui/browser_commands.h" |
| 16 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 18 #include "chrome/common/chrome_features.h" |
| 17 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
| 18 #include "chrome/test/base/in_process_browser_test.h" | 20 #include "chrome/test/base/in_process_browser_test.h" |
| 19 #include "chrome/test/base/ui_test_utils.h" | 21 #include "chrome/test/base/ui_test_utils.h" |
| 20 #include "content/public/common/url_constants.h" | 22 #include "content/public/common/url_constants.h" |
| 21 #include "content/public/test/browser_test_utils.h" | 23 #include "content/public/test/browser_test_utils.h" |
| 22 #include "grit/components_strings.h" | 24 #include "grit/components_strings.h" |
| 23 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
| 24 #include "testing/gmock/include/gmock/gmock.h" | 26 #include "testing/gmock/include/gmock/gmock.h" |
| 25 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
| 26 #include "url/gurl.h" | 28 #include "url/gurl.h" |
| 27 | 29 |
| 28 using base::Bucket; | 30 using base::Bucket; |
| 29 using testing::ElementsAre; | 31 using testing::ElementsAre; |
| 30 | 32 |
| 31 namespace webui { | 33 namespace webui { |
| 32 | 34 |
| 33 class LogWebUIUrlTest : public InProcessBrowserTest { | 35 class LogWebUIUrlTest : public InProcessBrowserTest { |
| 34 public: | 36 public: |
| 35 LogWebUIUrlTest() {} | 37 LogWebUIUrlTest() {} |
| 36 ~LogWebUIUrlTest() override {} | 38 ~LogWebUIUrlTest() override {} |
| 37 | 39 |
| 38 std::vector<Bucket> GetSamples() { | 40 std::vector<Bucket> GetSamples() { |
| 39 return histogram_tester_.GetAllSamples(webui::kWebUICreatedForUrl); | 41 return histogram_tester_.GetAllSamples(webui::kWebUICreatedForUrl); |
| 40 } | 42 } |
| 41 | 43 |
| 44 void SetUpOnMainThread() override { |
| 45 // Disable MD History to test non-MD history page. |
| 46 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); |
| 47 feature_list->InitializeFromCommandLine( |
| 48 std::string(), features::kMaterialDesignHistoryFeature.name); |
| 49 base::FeatureList::ClearInstanceForTesting(); |
| 50 base::FeatureList::SetInstance(std::move(feature_list)); |
| 51 } |
| 52 |
| 42 private: | 53 private: |
| 43 base::HistogramTester histogram_tester_; | 54 base::HistogramTester histogram_tester_; |
| 44 | 55 |
| 45 DISALLOW_COPY_AND_ASSIGN(LogWebUIUrlTest); | 56 DISALLOW_COPY_AND_ASSIGN(LogWebUIUrlTest); |
| 46 }; | 57 }; |
| 47 | 58 |
| 48 IN_PROC_BROWSER_TEST_F(LogWebUIUrlTest, TestHistoryFrame) { | 59 IN_PROC_BROWSER_TEST_F(LogWebUIUrlTest, TestHistoryFrame) { |
| 49 GURL history_frame_url(chrome::kChromeUIHistoryFrameURL); | 60 GURL history_frame_url(chrome::kChromeUIHistoryFrameURL); |
| 50 | 61 |
| 51 ui_test_utils::NavigateToURL(browser(), history_frame_url); | 62 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()); | 121 uint32_t extensions_frame_url_hash = base::Hash(extensions_frame_url.spec()); |
| 111 | 122 |
| 112 EXPECT_THAT(GetSamples(), ElementsAre(Bucket(extensions_frame_url_hash, 1), | 123 EXPECT_THAT(GetSamples(), ElementsAre(Bucket(extensions_frame_url_hash, 1), |
| 113 Bucket(history_frame_url_hash, 2), | 124 Bucket(history_frame_url_hash, 2), |
| 114 Bucket(uber_frame_url_hash, 2), | 125 Bucket(uber_frame_url_hash, 2), |
| 115 Bucket(uber_url_hash, 2))); | 126 Bucket(uber_url_hash, 2))); |
| 116 } | 127 } |
| 117 #endif | 128 #endif |
| 118 | 129 |
| 119 } // namespace webui | 130 } // namespace webui |
| OLD | NEW |