| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 11 #include "base/test/histogram_tester.h" | 11 #include "base/test/histogram_tester.h" |
| 12 #include "chrome/browser/ui/browser.h" |
| 12 #include "chrome/browser/ui/simple_message_box_internal.h" | 13 #include "chrome/browser/ui/simple_message_box_internal.h" |
| 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 13 #include "chrome/common/chrome_constants.h" | 15 #include "chrome/common/chrome_constants.h" |
| 14 #include "chrome/common/chrome_paths.h" | 16 #include "chrome/common/chrome_paths.h" |
| 15 #include "chrome/test/base/in_process_browser_test.h" | 17 #include "chrome/test/base/in_process_browser_test.h" |
| 16 #include "chrome/test/base/testing_profile.h" | 18 #include "chrome/test/base/testing_profile.h" |
| 17 #include "chrome/test/base/ui_test_utils.h" | 19 #include "chrome/test/base/ui_test_utils.h" |
| 20 #include "content/public/test/browser_test_utils.h" |
| 18 | 21 |
| 19 namespace { | 22 namespace { |
| 20 | 23 |
| 21 class ProfileErrorBrowserTest : public InProcessBrowserTest, | 24 class ProfileErrorBrowserTest : public InProcessBrowserTest, |
| 22 public testing::WithParamInterface<bool> { | 25 public testing::WithParamInterface<bool> { |
| 23 // A fixture that allows testing histograms reporting when faced with a | 26 // A fixture that allows testing histograms reporting when faced with a |
| 24 // corrupted profile. The boolean parameter forces the creation of an empty or | 27 // corrupted profile. The boolean parameter forces the creation of an empty or |
| 25 // corrupted profile, allowing to test both the corruption case and that what | 28 // corrupted profile, allowing to test both the corruption case and that what |
| 26 // it is testing indeed happens differently when not under corruption. | 29 // it is testing indeed happens differently when not under corruption. |
| 27 public: | 30 public: |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 #else | 79 #else |
| 77 #define MAYBE_CorruptedProfile CorruptedProfile | 80 #define MAYBE_CorruptedProfile CorruptedProfile |
| 78 #endif | 81 #endif |
| 79 | 82 |
| 80 IN_PROC_BROWSER_TEST_P(ProfileErrorBrowserTest, MAYBE_CorruptedProfile) { | 83 IN_PROC_BROWSER_TEST_P(ProfileErrorBrowserTest, MAYBE_CorruptedProfile) { |
| 81 const char kPaintHistogram[] = "Startup.FirstWebContents.NonEmptyPaint"; | 84 const char kPaintHistogram[] = "Startup.FirstWebContents.NonEmptyPaint"; |
| 82 const char kLoadHistogram[] = "Startup.FirstWebContents.MainFrameLoad"; | 85 const char kLoadHistogram[] = "Startup.FirstWebContents.MainFrameLoad"; |
| 83 | 86 |
| 84 // Navigate to a URL so the first non-empty paint is registered. | 87 // Navigate to a URL so the first non-empty paint is registered. |
| 85 ui_test_utils::NavigateToURL(browser(), GURL("http://www.example.com/")); | 88 ui_test_utils::NavigateToURL(browser(), GURL("http://www.example.com/")); |
| 89 |
| 90 content::WebContents* contents = |
| 91 browser()->tab_strip_model()->GetActiveWebContents(); |
| 92 |
| 93 // Wait for the page to produce a frame, the first visually non-empty paint |
| 94 // metric is not valid until then. |
| 95 bool loaded = false; |
| 96 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 97 contents, |
| 98 "requestAnimationFrame(function() {" |
| 99 " window.domAutomationController.send(true);" |
| 100 "});", |
| 101 &loaded)); |
| 102 ASSERT_TRUE(loaded); |
| 103 |
| 86 if (do_corrupt_) { | 104 if (do_corrupt_) { |
| 87 histogram_tester_.ExpectTotalCount(kPaintHistogram, 0); | 105 histogram_tester_.ExpectTotalCount(kPaintHistogram, 0); |
| 88 histogram_tester_.ExpectTotalCount(kLoadHistogram, 0); | 106 histogram_tester_.ExpectTotalCount(kLoadHistogram, 0); |
| 89 } else { | 107 } else { |
| 90 histogram_tester_.ExpectTotalCount(kPaintHistogram, 1); | 108 histogram_tester_.ExpectTotalCount(kPaintHistogram, 1); |
| 91 histogram_tester_.ExpectTotalCount(kLoadHistogram, 1); | 109 histogram_tester_.ExpectTotalCount(kLoadHistogram, 1); |
| 92 } | 110 } |
| 93 } | 111 } |
| 94 | 112 |
| 95 INSTANTIATE_TEST_CASE_P(ProfileErrorBrowserTestInstance, | 113 INSTANTIATE_TEST_CASE_P(ProfileErrorBrowserTestInstance, |
| 96 ProfileErrorBrowserTest, | 114 ProfileErrorBrowserTest, |
| 97 testing::Bool()); | 115 testing::Bool()); |
| 98 | 116 |
| 99 } // namespace | 117 } // namespace |
| OLD | NEW |