OLD | NEW |
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include <glib.h> | 8 #include <glib.h> |
9 | 9 |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 ActionProcessor processor; | 276 ActionProcessor processor; |
277 processor.set_delegate(&delegate); | 277 processor.set_delegate(&delegate); |
278 processor.EnqueueAction(&action); | 278 processor.EnqueueAction(&action); |
279 | 279 |
280 g_timeout_add(0, &StartProcessorInRunLoop, &processor); | 280 g_timeout_add(0, &StartProcessorInRunLoop, &processor); |
281 g_main_loop_run(loop); | 281 g_main_loop_run(loop); |
282 g_main_loop_unref(loop); | 282 g_main_loop_unref(loop); |
283 EXPECT_FALSE(processor.IsRunning()); | 283 EXPECT_FALSE(processor.IsRunning()); |
284 } | 284 } |
285 | 285 |
| 286 TEST(OmahaRequestActionTest, SkipTest) { |
| 287 const string http_response("invalid xml>"); |
| 288 |
| 289 GMainLoop *loop = g_main_loop_new(g_main_context_default(), FALSE); |
| 290 |
| 291 NiceMock<PrefsMock> prefs; |
| 292 MockHttpFetcher* fetcher = new MockHttpFetcher(http_response.data(), |
| 293 http_response.size(), |
| 294 NULL); |
| 295 fetcher->set_never_use(true); |
| 296 OmahaRequestAction action(&prefs, kDefaultTestParams, |
| 297 new OmahaEvent(OmahaEvent::kTypeUpdateComplete), |
| 298 fetcher); // Passes fetcher ownership |
| 299 action.set_should_skip(true); |
| 300 OmahaRequestActionTestProcessorDelegate delegate; |
| 301 delegate.loop_ = loop; |
| 302 ActionProcessor processor; |
| 303 processor.set_delegate(&delegate); |
| 304 processor.EnqueueAction(&action); |
| 305 |
| 306 g_timeout_add(0, &StartProcessorInRunLoop, &processor); |
| 307 g_main_loop_run(loop); |
| 308 g_main_loop_unref(loop); |
| 309 EXPECT_FALSE(processor.IsRunning()); |
| 310 } |
| 311 |
286 TEST(OmahaRequestActionTest, InvalidXmlTest) { | 312 TEST(OmahaRequestActionTest, InvalidXmlTest) { |
287 OmahaResponse response; | 313 OmahaResponse response; |
288 ASSERT_FALSE( | 314 ASSERT_FALSE( |
289 TestUpdateCheck(NULL, // prefs | 315 TestUpdateCheck(NULL, // prefs |
290 kDefaultTestParams, | 316 kDefaultTestParams, |
291 "invalid xml>", | 317 "invalid xml>", |
292 -1, | 318 -1, |
293 kActionCodeOmahaRequestXMLParseError, | 319 kActionCodeOmahaRequestXMLParseError, |
294 &response, | 320 &response, |
295 NULL)); | 321 NULL)); |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
903 "", | 929 "", |
904 1500, | 930 1500, |
905 static_cast<ActionExitCode>( | 931 static_cast<ActionExitCode>( |
906 kActionCodeOmahaRequestHTTPResponseBase + 999), | 932 kActionCodeOmahaRequestHTTPResponseBase + 999), |
907 &response, | 933 &response, |
908 NULL)); | 934 NULL)); |
909 EXPECT_FALSE(response.update_exists); | 935 EXPECT_FALSE(response.update_exists); |
910 } | 936 } |
911 | 937 |
912 } // namespace chromeos_update_engine | 938 } // namespace chromeos_update_engine |
OLD | NEW |