This source file includes following definitions.
- TestFailureCallback
- TEST
- TestForwardBackwardCallback
- TEST
#include "base/bind.h"
#include "chrome/installer/util/callback_work_item.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
bool TestFailureCallback(const CallbackWorkItem& work_item) {
return false;
}
}
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,
};
bool TestForwardBackwardCallback(TestCallbackState* state,
const CallbackWorkItem& work_item) {
*state = work_item.IsRollback() ? TCS_CALLED_ROLLBACK : TCS_CALLED_FORWARD;
return true;
}
}
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);
}