| 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" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "base/test/histogram_tester.h" | 12 #include "base/test/histogram_tester.h" |
| 13 #include "base/test/test_reg_util_win.h" | 13 #include "base/test/test_reg_util_win.h" |
| 14 #include "base/win/registry.h" | 14 #include "base/win/registry.h" |
| 15 #include "components/browser_watcher/exit_funnel_win.h" | 15 #include "components/browser_watcher/exit_funnel_win.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 17 |
| 18 namespace browser_watcher { | 18 namespace browser_watcher { |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 const wchar_t kRegistryPath[] = L"Software\\WatcherMetricsProviderWinTest"; | 22 const wchar_t kRegistryPath[] = L"Software\\WatcherMetricsProviderWinTest"; |
| 23 | 23 |
| 24 class WatcherMetricsProviderWinTest : public testing::Test { | 24 class WatcherMetricsProviderWinTest : public testing::Test { |
| 25 public: | 25 public: |
| 26 typedef testing::Test Super; | 26 typedef testing::Test Super; |
| 27 | 27 |
| 28 virtual void SetUp() override { | 28 void SetUp() override { |
| 29 Super::SetUp(); | 29 Super::SetUp(); |
| 30 | 30 |
| 31 override_manager_.OverrideRegistry(HKEY_CURRENT_USER); | 31 override_manager_.OverrideRegistry(HKEY_CURRENT_USER); |
| 32 } | 32 } |
| 33 | 33 |
| 34 void AddProcessExitCode(bool use_own_pid, int exit_code) { | 34 void AddProcessExitCode(bool use_own_pid, int exit_code) { |
| 35 int pid = 0; | 35 int pid = 0; |
| 36 if (use_own_pid) { | 36 if (use_own_pid) { |
| 37 pid = base::GetCurrentProcId(); | 37 pid = base::GetCurrentProcId(); |
| 38 } else { | 38 } else { |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 histogram_tester_.ExpectTotalCount("Stability.ExitFunnel.One", 0); | 192 histogram_tester_.ExpectTotalCount("Stability.ExitFunnel.One", 0); |
| 193 histogram_tester_.ExpectTotalCount("Stability.ExitFunnel.Two", 0); | 193 histogram_tester_.ExpectTotalCount("Stability.ExitFunnel.Two", 0); |
| 194 histogram_tester_.ExpectTotalCount("Stability.ExitFunnel.Three", 0); | 194 histogram_tester_.ExpectTotalCount("Stability.ExitFunnel.Three", 0); |
| 195 | 195 |
| 196 // Make sure the subkey for the pseudo process has been deleted on reporting. | 196 // Make sure the subkey for the pseudo process has been deleted on reporting. |
| 197 base::win::RegistryKeyIterator it(HKEY_CURRENT_USER, kRegistryPath); | 197 base::win::RegistryKeyIterator it(HKEY_CURRENT_USER, kRegistryPath); |
| 198 ASSERT_EQ(it.SubkeyCount(), 1); | 198 ASSERT_EQ(it.SubkeyCount(), 1); |
| 199 } | 199 } |
| 200 | 200 |
| 201 } // namespace browser_watcher | 201 } // namespace browser_watcher |
| OLD | NEW |