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

Unified Diff: chrome/installer/util/callback_work_item_unittest.cc

Issue 10916018: Force COM machinery to notice that the path to the DelegateExecute verb handler has changed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed robert's comments Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/installer/util/callback_work_item.cc ('k') | chrome/installer/util/chromium_binaries_distribution.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/installer/util/callback_work_item_unittest.cc
diff --git a/chrome/installer/util/callback_work_item_unittest.cc b/chrome/installer/util/callback_work_item_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0c4a531b139b5dabde266c5a3200ec8d1b785d12
--- /dev/null
+++ b/chrome/installer/util/callback_work_item_unittest.cc
@@ -0,0 +1,54 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/bind.h"
+#include "chrome/installer/util/callback_work_item.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+// A callback that always fails (returns false).
+bool TestFailureCallback(const CallbackWorkItem& work_item) {
+ return false;
+}
+
+} // namespace
+
+// Test that the work item returns false when a callback returns failure.
+TEST(CallbackWorkItemTest, TestFailure) {
+ CallbackWorkItem work_item(base::Bind(&TestFailureCallback));
+
+ EXPECT_FALSE(work_item.Do());
+}
+
+namespace {
+
+enum TestCallbackState {
+ TCS_UNDEFINED,
+ TCS_CALLED_FORWARD,
+ TCS_CALLED_ROLLBACK,
+};
+
+// A callback that sets |state| according to whether it is rolling forward or
+// backward.
+bool TestForwardBackwardCallback(TestCallbackState* state,
+ const CallbackWorkItem& work_item) {
+ *state = work_item.IsRollback() ? TCS_CALLED_ROLLBACK : TCS_CALLED_FORWARD;
+ return true;
+}
+
+} // namespace
+
+// Test that the callback is invoked correclty during Do() and Rollback().
+TEST(CallbackWorkItemTest, TestForwardBackward) {
+ TestCallbackState state = TCS_UNDEFINED;
+
+ CallbackWorkItem work_item(base::Bind(&TestForwardBackwardCallback, &state));
+
+ EXPECT_TRUE(work_item.Do());
+ EXPECT_EQ(TCS_CALLED_FORWARD, state);
+
+ work_item.Rollback();
+ EXPECT_EQ(TCS_CALLED_ROLLBACK, state);
+}
« no previous file with comments | « chrome/installer/util/callback_work_item.cc ('k') | chrome/installer/util/chromium_binaries_distribution.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698