Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1094)

Side by Side Diff: components/crash/content/app/crash_keys_win_unittest.cc

Issue 2031833002: Remove FilePath usage from the CrashReporterClient interface on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unused constant to fix clang Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 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/crash/content/app/crash_keys_win.h" 5 #include "components/crash/content/app/crash_keys_win.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "breakpad/src/client/windows/common/ipc_protocol.h" 12 #include "breakpad/src/client/windows/common/ipc_protocol.h"
13 #include "components/crash/content/app/crash_reporter_client.h" 13 #include "components/crash/content/app/crash_reporter_client.h"
14 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 namespace breakpad { 17 namespace breakpad {
18 18
19 using testing::_; 19 using testing::_;
20 using testing::DoAll; 20 using testing::DoAll;
21 using testing::Return; 21 using testing::Return;
22 using testing::SetArgPointee; 22 using testing::SetArgPointee;
23 23
24 class MockCrashReporterClient : public crash_reporter::CrashReporterClient { 24 class MockCrashReporterClient : public crash_reporter::CrashReporterClient {
25 public: 25 public:
26 MOCK_METHOD1(GetAlternativeCrashDumpLocation, 26 MOCK_METHOD1(GetAlternativeCrashDumpLocation,
27 bool(base::FilePath* crash_dir)); 27 bool(base::string16* crash_dir));
28 MOCK_METHOD5(GetProductNameAndVersion, void(const base::FilePath& exe_path, 28 MOCK_METHOD5(GetProductNameAndVersion, void(const base::string16& exe_path,
29 base::string16* product_name, 29 base::string16* product_name,
30 base::string16* version, 30 base::string16* version,
31 base::string16* special_build, 31 base::string16* special_build,
32 base::string16* channel_name)); 32 base::string16* channel_name));
33 MOCK_METHOD3(ShouldShowRestartDialog, bool(base::string16* title, 33 MOCK_METHOD3(ShouldShowRestartDialog, bool(base::string16* title,
34 base::string16* message, 34 base::string16* message,
35 bool* is_rtl_locale)); 35 bool* is_rtl_locale));
36 MOCK_METHOD0(AboutToRestart, bool()); 36 MOCK_METHOD0(AboutToRestart, bool());
37 MOCK_METHOD1(GetDeferredUploadsSupported, bool(bool is_per_user_install)); 37 MOCK_METHOD1(GetDeferredUploadsSupported, bool(bool is_per_user_install));
38 MOCK_METHOD1(GetIsPerUserInstall, bool(const base::FilePath& exe_path)); 38 MOCK_METHOD1(GetIsPerUserInstall, bool(const base::string16& exe_path));
39 MOCK_METHOD1(GetShouldDumpLargerDumps, bool(bool is_per_user_install)); 39 MOCK_METHOD1(GetShouldDumpLargerDumps, bool(bool is_per_user_install));
40 MOCK_METHOD0(GetResultCodeRespawnFailed, int()); 40 MOCK_METHOD0(GetResultCodeRespawnFailed, int());
41 MOCK_METHOD0(InitBrowserCrashDumpsRegKey, void()); 41 MOCK_METHOD0(InitBrowserCrashDumpsRegKey, void());
42 MOCK_METHOD1(RecordCrashDumpAttempt, void(bool is_real_crash)); 42 MOCK_METHOD1(RecordCrashDumpAttempt, void(bool is_real_crash));
43 43
44 MOCK_METHOD2(GetProductNameAndVersion, void(std::string* product_name, 44 MOCK_METHOD2(GetProductNameAndVersion, void(std::string* product_name,
45 std::string* version)); 45 std::string* version));
46 MOCK_METHOD0(GetReporterLogFilename, base::FilePath()); 46 MOCK_METHOD0(GetReporterLogFilename, base::FilePath());
47 MOCK_METHOD1(GetCrashDumpLocation, bool(base::FilePath* crash_dir)); 47 MOCK_METHOD1(GetCrashDumpLocation, bool(base::string16* crash_dir));
48 MOCK_METHOD0(RegisterCrashKeys, size_t()); 48 MOCK_METHOD0(RegisterCrashKeys, size_t());
49 MOCK_METHOD0(IsRunningUnattended, bool()); 49 MOCK_METHOD0(IsRunningUnattended, bool());
50 MOCK_METHOD0(GetCollectStatsConsent, bool()); 50 MOCK_METHOD0(GetCollectStatsConsent, bool());
51 MOCK_METHOD1(ReportingIsEnforcedByPolicy, bool(bool* breakpad_enabled)); 51 MOCK_METHOD1(ReportingIsEnforcedByPolicy, bool(bool* breakpad_enabled));
52 MOCK_METHOD0(GetAndroidMinidumpDescriptor, int()); 52 MOCK_METHOD0(GetAndroidMinidumpDescriptor, int());
53 MOCK_METHOD1(EnableBreakpadForProcess, bool(const std::string& process_type)); 53 MOCK_METHOD1(EnableBreakpadForProcess, bool(const std::string& process_type));
54 }; 54 };
55 55
56 class CrashKeysWinTest : public testing::Test { 56 class CrashKeysWinTest : public testing::Test {
57 public: 57 public:
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 89
90 ASSERT_EQ(static_cast<CrashKeysWin*>(NULL), CrashKeysWin::keeper()); 90 ASSERT_EQ(static_cast<CrashKeysWin*>(NULL), CrashKeysWin::keeper());
91 } 91 }
92 92
93 // Tests the crash keys set up for the most common official build consumer 93 // Tests the crash keys set up for the most common official build consumer
94 // scenario. No policy controls, not running unattended and no explicit 94 // scenario. No policy controls, not running unattended and no explicit
95 // switches. 95 // switches.
96 TEST_F(CrashKeysWinTest, OfficialLikeKeys) { 96 TEST_F(CrashKeysWinTest, OfficialLikeKeys) {
97 CrashKeysWin crash_keys; 97 CrashKeysWin crash_keys;
98 98
99 const base::FilePath kExePath(L"C:\\temp\\exe_path.exe"); 99 const base::string16 kExePath(L"C:\\temp\\exe_path.exe");
100 // The exe path ought to get passed through to the breakpad client. 100 // The exe path ought to get passed through to the breakpad client.
101 EXPECT_CALL(crash_client_, GetProductNameAndVersion(kExePath, _, _, _, _)) 101 EXPECT_CALL(crash_client_, GetProductNameAndVersion(kExePath, _, _, _, _))
102 .WillRepeatedly(DoAll( 102 .WillRepeatedly(DoAll(
103 SetArgPointee<1>(L"SomeProdName"), 103 SetArgPointee<1>(L"SomeProdName"),
104 SetArgPointee<2>(L"1.2.3.4"), 104 SetArgPointee<2>(L"1.2.3.4"),
105 SetArgPointee<3>(L""), 105 SetArgPointee<3>(L""),
106 SetArgPointee<4>(L"-devm"))); 106 SetArgPointee<4>(L"-devm")));
107 107
108 EXPECT_CALL(crash_client_, GetAlternativeCrashDumpLocation(_)) 108 EXPECT_CALL(crash_client_, GetAlternativeCrashDumpLocation(_))
109 .WillRepeatedly(DoAll( 109 .WillRepeatedly(DoAll(
110 SetArgPointee<0>(base::FilePath(L"C:\\temp")), 110 SetArgPointee<0>(L"C:\\temp"),
111 Return(false))); 111 Return(false)));
112 112
113 EXPECT_CALL(crash_client_, ReportingIsEnforcedByPolicy(_)) 113 EXPECT_CALL(crash_client_, ReportingIsEnforcedByPolicy(_))
114 .WillRepeatedly(Return(false)); 114 .WillRepeatedly(Return(false));
115 115
116 EXPECT_CALL(crash_client_, IsRunningUnattended()) 116 EXPECT_CALL(crash_client_, IsRunningUnattended())
117 .WillRepeatedly(Return(false)); 117 .WillRepeatedly(Return(false));
118 118
119 // Provide an empty command line. 119 // Provide an empty command line.
120 base::CommandLine cmd_line(base::CommandLine::NO_PROGRAM); 120 base::CommandLine cmd_line(base::CommandLine::NO_PROGRAM);
121 google_breakpad::CustomClientInfo* info = 121 google_breakpad::CustomClientInfo* info =
122 crash_keys.GetCustomInfo(kExePath.value(), 122 crash_keys.GetCustomInfo(kExePath,
123 L"made_up_type", 123 L"made_up_type",
124 L"temporary", 124 L"temporary",
125 &cmd_line, 125 &cmd_line,
126 &crash_client_); 126 &crash_client_);
127 127
128 ASSERT_TRUE(info != NULL); 128 ASSERT_TRUE(info != NULL);
129 ASSERT_TRUE(info->entries != NULL); 129 ASSERT_TRUE(info->entries != NULL);
130 130
131 // We expect 7 fixed keys and a "freeboard" of 256 keys for dynamic entries. 131 // We expect 7 fixed keys and a "freeboard" of 256 keys for dynamic entries.
132 EXPECT_EQ(256U + 7U, info->count); 132 EXPECT_EQ(256U + 7U, info->count);
133 133
134 EXPECT_EQ(1u, CountKeyValueOccurences(info, L"ver", L"1.2.3.4")); 134 EXPECT_EQ(1u, CountKeyValueOccurences(info, L"ver", L"1.2.3.4"));
135 EXPECT_EQ(1u, CountKeyValueOccurences(info, L"prod", L"SomeProdName")); 135 EXPECT_EQ(1u, CountKeyValueOccurences(info, L"prod", L"SomeProdName"));
136 EXPECT_EQ(1u, CountKeyValueOccurences(info, L"plat", L"Win32")); 136 EXPECT_EQ(1u, CountKeyValueOccurences(info, L"plat", L"Win32"));
137 EXPECT_EQ(1u, CountKeyValueOccurences(info, L"ptype", L"made_up_type")); 137 EXPECT_EQ(1u, CountKeyValueOccurences(info, L"ptype", L"made_up_type"));
138 std::wstring pid_str(base::StringPrintf(L"%d", ::GetCurrentProcessId())); 138 std::wstring pid_str(base::StringPrintf(L"%d", ::GetCurrentProcessId()));
139 EXPECT_EQ(1u, CountKeyValueOccurences(info, L"pid", pid_str.c_str())); 139 EXPECT_EQ(1u, CountKeyValueOccurences(info, L"pid", pid_str.c_str()));
140 EXPECT_EQ(1u, CountKeyValueOccurences(info, L"channel", L"-devm")); 140 EXPECT_EQ(1u, CountKeyValueOccurences(info, L"channel", L"-devm"));
141 EXPECT_EQ(1u, CountKeyValueOccurences(info, L"profile-type", L"temporary")); 141 EXPECT_EQ(1u, CountKeyValueOccurences(info, L"profile-type", L"temporary"));
142 EXPECT_EQ(256u, CountKeyValueOccurences(info, L"unspecified-crash-key", L"")); 142 EXPECT_EQ(256u, CountKeyValueOccurences(info, L"unspecified-crash-key", L""));
143 } 143 }
144 144
145 } // namespace breakpad 145 } // namespace breakpad
OLDNEW
« no previous file with comments | « components/crash/content/app/crash_keys_win.cc ('k') | components/crash/content/app/crash_reporter_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698