Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(4)

Delta Between Two Patch Sets: src/common/linux/google_crashdump_uploader_test.cc

Issue 7714002: GoogleCrashdumpUploader: adds Upload(string*) API to get the HTTP response. (Closed) Base URL: http://google-breakpad.googlecode.com/svn/trunk/src/
Left Patch Set: Created 10 years, 6 months ago
Right Patch Set: Created 10 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/common/linux/google_crashdump_uploader.h ('k') | src/common/linux/libcurl_wrapper.cc » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright (c) 2009, Google Inc. 1 // Copyright (c) 2009, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 "AAA-BBB", 66 "AAA-BBB",
67 "", 67 "",
68 "", 68 "",
69 "test@test.com ", 69 "test@test.com ",
70 "none", 70 "none",
71 "/tmp/foo.dmp" , 71 "/tmp/foo.dmp" ,
72 "http://foo.co m", 72 "http://foo.co m",
73 "", 73 "",
74 "", 74 "",
75 &m); 75 &m);
76 ASSERT_FALSE(uploader->Upload()); 76 ASSERT_FALSE(uploader->Upload(NULL, NULL, NULL));
77 } 77 }
78 78
79 TEST_F(GoogleCrashdumpUploaderTest, TestSendRequestHappensWithValidParameters) { 79 TEST_F(GoogleCrashdumpUploaderTest, TestSendRequestHappensWithValidParameters) {
80 // Create a temp file 80 // Create a temp file
81 char tempfn[80] = "/tmp/googletest-upload-XXXXXX"; 81 char tempfn[80] = "/tmp/googletest-upload-XXXXXX";
82 int fd = mkstemp(tempfn); 82 int fd = mkstemp(tempfn);
83 ASSERT_NE(fd, -1); 83 ASSERT_NE(fd, -1);
84 close(fd); 84 close(fd);
85 85
86 MockLibcurlWrapper m; 86 MockLibcurlWrapper m;
87 EXPECT_CALL(m, Init()).Times(1).WillOnce(Return(true)); 87 EXPECT_CALL(m, Init()).Times(1).WillOnce(Return(true));
88 EXPECT_CALL(m, AddFile(tempfn, _)).WillOnce(Return(true)); 88 EXPECT_CALL(m, AddFile(tempfn, _)).WillOnce(Return(true));
89 EXPECT_CALL(m, 89 EXPECT_CALL(m,
90 SendRequest("http://foo.com",_,_,_,_)).Times(1).WillOnce(Return(tr ue)); 90 SendRequest("http://foo.com",_,_,_,_)).Times(1).WillOnce(Return(tr ue));
91 GoogleCrashdumpUploader *uploader = new GoogleCrashdumpUploader("foobar", 91 GoogleCrashdumpUploader *uploader = new GoogleCrashdumpUploader("foobar",
92 "1.0", 92 "1.0",
93 "AAA-BBB", 93 "AAA-BBB",
94 "", 94 "",
95 "", 95 "",
96 "test@test.com ", 96 "test@test.com ",
97 "none", 97 "none",
98 tempfn, 98 tempfn,
99 "http://foo.co m", 99 "http://foo.co m",
100 "", 100 "",
101 "", 101 "",
102 &m); 102 &m);
103 ASSERT_TRUE(uploader->Upload()); 103 ASSERT_TRUE(uploader->Upload(NULL, NULL, NULL));
104 } 104 }
105 105
106 106
107 TEST_F(GoogleCrashdumpUploaderTest, InvalidPathname) { 107 TEST_F(GoogleCrashdumpUploaderTest, InvalidPathname) {
108 MockLibcurlWrapper m; 108 MockLibcurlWrapper m;
109 EXPECT_CALL(m, Init()).Times(1).WillOnce(Return(true)); 109 EXPECT_CALL(m, Init()).Times(1).WillOnce(Return(true));
110 EXPECT_CALL(m, SendRequest(_,_,_,_,_)).Times(0); 110 EXPECT_CALL(m, SendRequest(_,_,_,_,_)).Times(0);
111 GoogleCrashdumpUploader *uploader = new GoogleCrashdumpUploader("foobar", 111 GoogleCrashdumpUploader *uploader = new GoogleCrashdumpUploader("foobar",
112 "1.0", 112 "1.0",
113 "AAA-BBB", 113 "AAA-BBB",
114 "", 114 "",
115 "", 115 "",
116 "test@test.com ", 116 "test@test.com ",
117 "none", 117 "none",
118 "/tmp/foo.dmp" , 118 "/tmp/foo.dmp" ,
119 "http://foo.co m", 119 "http://foo.co m",
120 "", 120 "",
121 "", 121 "",
122 &m); 122 &m);
123 ASSERT_FALSE(uploader->Upload()); 123 ASSERT_FALSE(uploader->Upload(NULL, NULL, NULL));
124 } 124 }
125 125
126 TEST_F(GoogleCrashdumpUploaderTest, TestRequiredParametersMustBePresent) { 126 TEST_F(GoogleCrashdumpUploaderTest, TestRequiredParametersMustBePresent) {
127 // Test with empty product name. 127 // Test with empty product name.
128 GoogleCrashdumpUploader uploader("", 128 GoogleCrashdumpUploader uploader("",
129 "1.0", 129 "1.0",
130 "AAA-BBB", 130 "AAA-BBB",
131 "", 131 "",
132 "", 132 "",
133 "test@test.com", 133 "test@test.com",
134 "none", 134 "none",
135 "/tmp/foo.dmp", 135 "/tmp/foo.dmp",
136 "http://foo.com", 136 "http://foo.com",
137 "", 137 "",
138 ""); 138 "");
139 ASSERT_FALSE(uploader.Upload()); 139 ASSERT_FALSE(uploader.Upload(NULL, NULL, NULL));
140 140
141 // Test with empty product version. 141 // Test with empty product version.
142 GoogleCrashdumpUploader uploader1("product", 142 GoogleCrashdumpUploader uploader1("product",
143 "", 143 "",
144 "AAA-BBB", 144 "AAA-BBB",
145 "", 145 "",
146 "", 146 "",
147 "", 147 "",
148 "", 148 "",
149 "/tmp/foo.dmp", 149 "/tmp/foo.dmp",
150 "", 150 "",
151 "", 151 "",
152 ""); 152 "");
153 153
154 ASSERT_FALSE(uploader1.Upload()); 154 ASSERT_FALSE(uploader1.Upload(NULL, NULL, NULL));
155 155
156 // Test with empty client GUID. 156 // Test with empty client GUID.
157 GoogleCrashdumpUploader uploader2("product", 157 GoogleCrashdumpUploader uploader2("product",
158 "1.0", 158 "1.0",
159 "", 159 "",
160 "", 160 "",
161 "", 161 "",
162 "", 162 "",
163 "", 163 "",
164 "/tmp/foo.dmp", 164 "/tmp/foo.dmp",
165 "", 165 "",
166 "", 166 "",
167 ""); 167 "");
168 ASSERT_FALSE(uploader2.Upload()); 168 ASSERT_FALSE(uploader2.Upload(NULL, NULL, NULL));
169 } 169 }
170 } 170 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld 1004:630ec63f810e-tainted