Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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 "components/browser_watcher/watcher_metrics_provider_win.h" | 5 #include "components/browser_watcher/watcher_metrics_provider_win.h" |
| 6 | 6 |
| 7 #include <cstdlib> | 7 #include <cstdlib> |
| 8 | 8 |
| 9 #include "base/process/process_handle.h" | 9 #include "base/process/process_handle.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 | 131 |
| 132 // Make sure the subkey is deleted on reporting. | 132 // Make sure the subkey is deleted on reporting. |
| 133 base::win::RegistryKeyIterator it(HKEY_CURRENT_USER, kRegistryPath); | 133 base::win::RegistryKeyIterator it(HKEY_CURRENT_USER, kRegistryPath); |
| 134 ASSERT_EQ(it.SubkeyCount(), 0); | 134 ASSERT_EQ(it.SubkeyCount(), 0); |
| 135 } | 135 } |
| 136 | 136 |
| 137 TEST_F(WatcherMetricsProviderWinTest, ReadsExitFunnelWrites) { | 137 TEST_F(WatcherMetricsProviderWinTest, ReadsExitFunnelWrites) { |
| 138 // Test that the metrics provider picks up the writes from | 138 // Test that the metrics provider picks up the writes from |
| 139 ExitFunnel funnel; | 139 ExitFunnel funnel; |
| 140 | 140 |
| 141 // Events against our own process should not get reported. | |
| 141 ASSERT_TRUE(funnel.Init(kRegistryPath, base::GetCurrentProcessHandle())); | 142 ASSERT_TRUE(funnel.Init(kRegistryPath, base::GetCurrentProcessHandle())); |
| 143 ASSERT_TRUE(funnel.RecordEvent(L"Forgetaboutit")); | |
| 144 | |
| 145 // Reset the funnel to a pseudo process. The PID 4 is the system process, | |
| 146 // which tests can hopefully never open. | |
| 147 ASSERT_TRUE(funnel.InitImpl(kRegistryPath, 4, base::Time::Now())); | |
|
erikwright (departed)
2014/12/19 20:03:38
I don't understand the purpose of this. Is it to t
| |
| 142 | 148 |
| 143 // Each named event can only exist in a single copy. | 149 // Each named event can only exist in a single copy. |
| 144 ASSERT_TRUE(funnel.RecordEvent(L"One")); | 150 ASSERT_TRUE(funnel.RecordEvent(L"One")); |
| 145 ASSERT_TRUE(funnel.RecordEvent(L"One")); | 151 ASSERT_TRUE(funnel.RecordEvent(L"One")); |
| 146 ASSERT_TRUE(funnel.RecordEvent(L"One")); | 152 ASSERT_TRUE(funnel.RecordEvent(L"One")); |
| 147 ASSERT_TRUE(funnel.RecordEvent(L"Two")); | 153 ASSERT_TRUE(funnel.RecordEvent(L"Two")); |
| 148 ASSERT_TRUE(funnel.RecordEvent(L"Three")); | 154 ASSERT_TRUE(funnel.RecordEvent(L"Three")); |
| 149 | 155 |
| 150 WatcherMetricsProviderWin provider(kRegistryPath); | 156 WatcherMetricsProviderWin provider(kRegistryPath); |
| 151 | 157 |
| 152 provider.ProvideStabilityMetrics(NULL); | 158 provider.ProvideStabilityMetrics(NULL); |
| 153 histogram_tester_.ExpectTotalCount("Stability.ExitFunnel.One", 1); | 159 histogram_tester_.ExpectTotalCount("Stability.ExitFunnel.One", 1); |
| 154 histogram_tester_.ExpectTotalCount("Stability.ExitFunnel.Two", 1); | 160 histogram_tester_.ExpectTotalCount("Stability.ExitFunnel.Two", 1); |
| 155 histogram_tester_.ExpectTotalCount("Stability.ExitFunnel.Three", 1); | 161 histogram_tester_.ExpectTotalCount("Stability.ExitFunnel.Three", 1); |
| 156 | 162 |
| 157 // Make sure the subkey has been deleted on reporting. | 163 // Make sure the subkey for the pseudo process has been deleted on reporting. |
| 158 base::win::RegistryKeyIterator it(HKEY_CURRENT_USER, kRegistryPath); | 164 base::win::RegistryKeyIterator it(HKEY_CURRENT_USER, kRegistryPath); |
| 159 ASSERT_EQ(it.SubkeyCount(), 0); | 165 ASSERT_EQ(it.SubkeyCount(), 1); |
| 160 } | 166 } |
| 161 | 167 |
| 162 } // namespace browser_watcher | 168 } // namespace browser_watcher |
| OLD | NEW |