Chromium Code Reviews| Index: components/browser_watcher/watcher_metrics_provider_win_unittest.cc |
| diff --git a/components/browser_watcher/watcher_metrics_provider_win_unittest.cc b/components/browser_watcher/watcher_metrics_provider_win_unittest.cc |
| index 838b12deca2331f18f3f0c2d80eeb2d1f88928da..0ac6f9e1ac3569b6bb898ffbf49ba4f658ac94e5 100644 |
| --- a/components/browser_watcher/watcher_metrics_provider_win_unittest.cc |
| +++ b/components/browser_watcher/watcher_metrics_provider_win_unittest.cc |
| @@ -81,7 +81,7 @@ TEST_F(WatcherMetricsProviderWinTest, RecordsStabilityHistogram) { |
| // Record a single failure. |
| AddProcessExitCode(false, 100); |
| - WatcherMetricsProviderWin provider(kRegistryPath); |
| + WatcherMetricsProviderWin provider(kRegistryPath, true); |
| provider.ProvideStabilityMetrics(NULL); |
| histogram_tester_.ExpectBucketCount( |
| @@ -103,7 +103,7 @@ TEST_F(WatcherMetricsProviderWinTest, DoesNotReportOwnProcessId) { |
| // Record own process as STILL_ACTIVE. |
| AddProcessExitCode(true, STILL_ACTIVE); |
| - WatcherMetricsProviderWin provider(kRegistryPath); |
| + WatcherMetricsProviderWin provider(kRegistryPath, true); |
| provider.ProvideStabilityMetrics(NULL); |
| histogram_tester_.ExpectUniqueSample( |
| @@ -122,7 +122,7 @@ TEST_F(WatcherMetricsProviderWinTest, RecordsOrderedExitFunnelEvents) { |
| AddExitFunnelEvent(100, L"Two", 1010 * 1000); |
| AddExitFunnelEvent(100, L"Three", 990 * 1000); |
| - WatcherMetricsProviderWin provider(kRegistryPath); |
| + WatcherMetricsProviderWin provider(kRegistryPath, true); |
| provider.ProvideStabilityMetrics(NULL); |
| histogram_tester_.ExpectUniqueSample("Stability.ExitFunnel.Three", 0, 1); |
| @@ -153,7 +153,7 @@ TEST_F(WatcherMetricsProviderWinTest, ReadsExitFunnelWrites) { |
| ASSERT_TRUE(funnel.RecordEvent(L"Two")); |
| ASSERT_TRUE(funnel.RecordEvent(L"Three")); |
| - WatcherMetricsProviderWin provider(kRegistryPath); |
| + WatcherMetricsProviderWin provider(kRegistryPath, true); |
| provider.ProvideStabilityMetrics(NULL); |
| histogram_tester_.ExpectTotalCount("Stability.ExitFunnel.One", 1); |
| @@ -165,4 +165,36 @@ TEST_F(WatcherMetricsProviderWinTest, ReadsExitFunnelWrites) { |
| ASSERT_EQ(it.SubkeyCount(), 1); |
| } |
| +TEST_F(WatcherMetricsProviderWinTest, ClearsExitFunnelWriteWhenNotReporting) { |
| + // Test that the metrics provider picks up the writes from |
|
Alexei Svitkine (slow)
2015/01/23 18:45:22
Incomplete sentence?
Sigurður Ásgeirsson
2015/01/23 18:48:43
Done.
|
| + ExitFunnel funnel; |
| + |
| + // Events against our own process should not get reported. |
| + ASSERT_TRUE(funnel.Init(kRegistryPath, base::GetCurrentProcessHandle())); |
| + ASSERT_TRUE(funnel.RecordEvent(L"Forgetaboutit")); |
| + |
| + // Reset the funnel to a pseudo process. The PID 4 is the system process, |
| + // which tests can hopefully never open. |
| + ASSERT_TRUE(funnel.InitImpl(kRegistryPath, 4, base::Time::Now())); |
| + |
| + // Each named event can only exist in a single copy. |
| + ASSERT_TRUE(funnel.RecordEvent(L"One")); |
| + ASSERT_TRUE(funnel.RecordEvent(L"One")); |
| + ASSERT_TRUE(funnel.RecordEvent(L"One")); |
| + ASSERT_TRUE(funnel.RecordEvent(L"Two")); |
| + ASSERT_TRUE(funnel.RecordEvent(L"Three")); |
| + |
| + // Turn off exit funnel reporting. |
| + WatcherMetricsProviderWin provider(kRegistryPath, false); |
| + |
| + provider.ProvideStabilityMetrics(NULL); |
| + histogram_tester_.ExpectTotalCount("Stability.ExitFunnel.One", 0); |
| + histogram_tester_.ExpectTotalCount("Stability.ExitFunnel.Two", 0); |
| + histogram_tester_.ExpectTotalCount("Stability.ExitFunnel.Three", 0); |
| + |
| + // Make sure the subkey for the pseudo process has been deleted on reporting. |
| + base::win::RegistryKeyIterator it(HKEY_CURRENT_USER, kRegistryPath); |
| + ASSERT_EQ(it.SubkeyCount(), 1); |
| +} |
| + |
| } // namespace browser_watcher |