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