| Index: blimp/engine/app/blimp_stability_metrics_provider_unittest.cc
|
| diff --git a/chrome/browser/metrics/chrome_stability_metrics_provider_unittest.cc b/blimp/engine/app/blimp_stability_metrics_provider_unittest.cc
|
| similarity index 53%
|
| copy from chrome/browser/metrics/chrome_stability_metrics_provider_unittest.cc
|
| copy to blimp/engine/app/blimp_stability_metrics_provider_unittest.cc
|
| index a23da907f093fd6e16f71d49c88660e255a98736..f5a38806407054ff7e0353aabf424f0061578e7f 100644
|
| --- a/chrome/browser/metrics/chrome_stability_metrics_provider_unittest.cc
|
| +++ b/blimp/engine/app/blimp_stability_metrics_provider_unittest.cc
|
| @@ -2,12 +2,9 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "chrome/browser/metrics/chrome_stability_metrics_provider.h"
|
| +#include "blimp/engine/app/blimp_stability_metrics_provider.h"
|
|
|
| #include "base/macros.h"
|
| -#include "chrome/test/base/testing_browser_process.h"
|
| -#include "chrome/test/base/testing_profile.h"
|
| -#include "chrome/test/base/testing_profile_manager.h"
|
| #include "components/metrics/proto/system_profile.pb.h"
|
| #include "components/prefs/pref_service.h"
|
| #include "components/prefs/scoped_user_pref_update.h"
|
| @@ -15,6 +12,7 @@
|
| #include "content/public/browser/browser_context.h"
|
| #include "content/public/browser/child_process_data.h"
|
| #include "content/public/browser/notification_details.h"
|
| +#include "content/public/browser/notification_service.h"
|
| #include "content/public/browser/notification_source.h"
|
| #include "content/public/browser/notification_types.h"
|
| #include "content/public/browser/render_process_host.h"
|
| @@ -24,15 +22,11 @@
|
| #include "content/public/test/test_browser_thread_bundle.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| -#if defined(ENABLE_EXTENSIONS)
|
| -#include "extensions/browser/process_map.h"
|
| -#endif
|
| -
|
| namespace {
|
|
|
| -class ChromeStabilityMetricsProviderTest : public testing::Test {
|
| +class BlimpStabilityMetricsProviderTest : public testing::Test {
|
| protected:
|
| - ChromeStabilityMetricsProviderTest() : prefs_(new TestingPrefServiceSimple) {
|
| + BlimpStabilityMetricsProviderTest() : prefs_(new TestingPrefServiceSimple) {
|
| metrics::StabilityMetricsHelper::RegisterPrefs(prefs()->registry());
|
| }
|
|
|
| @@ -42,13 +36,13 @@ class ChromeStabilityMetricsProviderTest : public testing::Test {
|
| std::unique_ptr<TestingPrefServiceSimple> prefs_;
|
| content::TestBrowserThreadBundle thread_bundle_;
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(ChromeStabilityMetricsProviderTest);
|
| + DISALLOW_COPY_AND_ASSIGN(BlimpStabilityMetricsProviderTest);
|
| };
|
|
|
| } // namespace
|
|
|
| -TEST_F(ChromeStabilityMetricsProviderTest, BrowserChildProcessObserver) {
|
| - ChromeStabilityMetricsProvider provider(prefs());
|
| +TEST_F(BlimpStabilityMetricsProviderTest, BrowserChildProcessObserver) {
|
| + BlimpStabilityMetricsProvider provider(prefs());
|
|
|
| content::ChildProcessData child_process_data(content::PROCESS_TYPE_RENDERER);
|
| provider.BrowserChildProcessCrashed(child_process_data, 1);
|
| @@ -67,39 +61,28 @@ TEST_F(ChromeStabilityMetricsProviderTest, BrowserChildProcessObserver) {
|
| EXPECT_EQ(2, stability.child_process_crash_count());
|
| }
|
|
|
| -TEST_F(ChromeStabilityMetricsProviderTest, NotificationObserver) {
|
| - ChromeStabilityMetricsProvider provider(prefs());
|
| - std::unique_ptr<TestingProfileManager> profile_manager(
|
| - new TestingProfileManager(TestingBrowserProcess::GetGlobal()));
|
| - EXPECT_TRUE(profile_manager->SetUp());
|
| -
|
| - // Owned by profile_manager.
|
| - TestingProfile* profile(
|
| - profile_manager->CreateTestingProfile("StabilityTestProfile"));
|
| -
|
| - std::unique_ptr<content::MockRenderProcessHostFactory> rph_factory(
|
| - new content::MockRenderProcessHostFactory());
|
| - scoped_refptr<content::SiteInstance> site_instance(
|
| - content::SiteInstance::Create(profile));
|
| +TEST_F(BlimpStabilityMetricsProviderTest, NotificationObserver) {
|
| + BlimpStabilityMetricsProvider provider(prefs());
|
| + content::NotificationSource irrelevant_source =
|
| + content::Source<std::nullptr_t>(nullptr);
|
|
|
| - // Owned by rph_factory.
|
| - content::RenderProcessHost* host(
|
| - rph_factory->CreateRenderProcessHost(profile, site_instance.get()));
|
| + // Load start should increase page load count.
|
| + provider.Observe(
|
| + content::NOTIFICATION_LOAD_START, irrelevant_source,
|
| + content::NotificationService::NoDetails());
|
|
|
| // Crash and abnormal termination should increment renderer crash count.
|
| content::RenderProcessHost::RendererClosedDetails crash_details(
|
| base::TERMINATION_STATUS_PROCESS_CRASHED, 1);
|
| provider.Observe(
|
| - content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
|
| - content::Source<content::RenderProcessHost>(host),
|
| + content::NOTIFICATION_RENDERER_PROCESS_CLOSED, irrelevant_source,
|
| content::Details<content::RenderProcessHost::RendererClosedDetails>(
|
| &crash_details));
|
|
|
| content::RenderProcessHost::RendererClosedDetails term_details(
|
| base::TERMINATION_STATUS_ABNORMAL_TERMINATION, 1);
|
| provider.Observe(
|
| - content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
|
| - content::Source<content::RenderProcessHost>(host),
|
| + content::NOTIFICATION_RENDERER_PROCESS_CLOSED, irrelevant_source,
|
| content::Details<content::RenderProcessHost::RendererClosedDetails>(
|
| &term_details));
|
|
|
| @@ -107,8 +90,7 @@ TEST_F(ChromeStabilityMetricsProviderTest, NotificationObserver) {
|
| content::RenderProcessHost::RendererClosedDetails kill_details(
|
| base::TERMINATION_STATUS_PROCESS_WAS_KILLED, 1);
|
| provider.Observe(
|
| - content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
|
| - content::Source<content::RenderProcessHost>(host),
|
| + content::NOTIFICATION_RENDERER_PROCESS_CLOSED, irrelevant_source,
|
| content::Details<content::RenderProcessHost::RendererClosedDetails>(
|
| &kill_details));
|
|
|
| @@ -116,8 +98,7 @@ TEST_F(ChromeStabilityMetricsProviderTest, NotificationObserver) {
|
| content::RenderProcessHost::RendererClosedDetails failed_launch_details(
|
| base::TERMINATION_STATUS_LAUNCH_FAILED, 1);
|
| provider.Observe(
|
| - content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
|
| - content::Source<content::RenderProcessHost>(host),
|
| + content::NOTIFICATION_RENDERER_PROCESS_CLOSED, irrelevant_source,
|
| content::Details<content::RenderProcessHost::RendererClosedDetails>(
|
| &failed_launch_details));
|
|
|
| @@ -127,43 +108,8 @@ TEST_F(ChromeStabilityMetricsProviderTest, NotificationObserver) {
|
| // be executed immediately.
|
| provider.ProvideStabilityMetrics(&system_profile);
|
|
|
| + EXPECT_EQ(1, system_profile.stability().page_load_count());
|
| EXPECT_EQ(2, system_profile.stability().renderer_crash_count());
|
| EXPECT_EQ(1, system_profile.stability().renderer_failed_launch_count());
|
| EXPECT_EQ(0, system_profile.stability().extension_renderer_crash_count());
|
| -
|
| -#if defined(ENABLE_EXTENSIONS)
|
| - provider.ClearSavedStabilityMetrics();
|
| -
|
| - // Owned by rph_factory.
|
| - content::RenderProcessHost* extension_host(
|
| - rph_factory->CreateRenderProcessHost(profile, site_instance.get()));
|
| -
|
| - // Make the rph an extension rph.
|
| - extensions::ProcessMap::Get(profile)
|
| - ->Insert("1", extension_host->GetID(), site_instance->GetId());
|
| -
|
| - // Crash and abnormal termination should increment extension crash count.
|
| - provider.Observe(
|
| - content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
|
| - content::Source<content::RenderProcessHost>(extension_host),
|
| - content::Details<content::RenderProcessHost::RendererClosedDetails>(
|
| - &crash_details));
|
| -
|
| - // Failed launch increments failed launch count.
|
| - provider.Observe(
|
| - content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
|
| - content::Source<content::RenderProcessHost>(extension_host),
|
| - content::Details<content::RenderProcessHost::RendererClosedDetails>(
|
| - &failed_launch_details));
|
| -
|
| - system_profile.Clear();
|
| - provider.ProvideStabilityMetrics(&system_profile);
|
| -
|
| - EXPECT_EQ(0, system_profile.stability().renderer_crash_count());
|
| - EXPECT_EQ(1, system_profile.stability().extension_renderer_crash_count());
|
| - EXPECT_EQ(
|
| - 1, system_profile.stability().extension_renderer_failed_launch_count());
|
| -#endif
|
| -
|
| - profile_manager->DeleteAllTestingProfiles();
|
| }
|
|
|