|
@@ -2374,6 +2374,87 @@ TEST(testClosekey, Negative) {
|
|
|
EXPECT_TRUE(cm.isLoggedIn());
|
|
|
}
|
|
|
|
|
|
+/* =====================================
|
|
|
+ * test for notifications
|
|
|
+ */
|
|
|
+TEST(testNotifications, Positive) {
|
|
|
+ FileManMock fm;
|
|
|
+ CmdManForTest cm(fm, dummyDebugPrint);
|
|
|
+ cm.initLoggedIn();
|
|
|
+
|
|
|
+ std::string cmd;
|
|
|
+ std::vector<std::string> args;
|
|
|
+ Json::Value root, messagesArr;
|
|
|
+ CmdMan::CmdRet retvalCmd;
|
|
|
+ CmdMan::CmdRet retvalHdl;
|
|
|
+ vector<string> msgvec = {"msg1", "msg2", "msg3 foo", "msg4 hello world!"};
|
|
|
+
|
|
|
+ // prepare cmd/args/root
|
|
|
+ cmd = "notifications";
|
|
|
+ args = {};
|
|
|
+ root["command"] = "notifications";
|
|
|
+ for (string s : msgvec)
|
|
|
+ messagesArr.append(s);
|
|
|
+ root["messages"] = messagesArr;
|
|
|
+ root["accept"] = true;
|
|
|
+
|
|
|
+ // stick into cmdman
|
|
|
+ retvalCmd = cm.execute(cmd, args);
|
|
|
+ retvalHdl = cm.handle(root);
|
|
|
+
|
|
|
+ // check things
|
|
|
+ EXPECT_EQ(retvalCmd.type, CmdMan::send);
|
|
|
+ EXPECT_EQ(retvalCmd.msg["command"].asString(), "notifications");
|
|
|
+
|
|
|
+ EXPECT_EQ(retvalHdl.type, CmdMan::print);
|
|
|
+ EXPECT_EQ(retvalHdl.msg["command"].asString(), "notifications");
|
|
|
+ EXPECT_TRUE(retvalHdl.msg["accept"].asBool());
|
|
|
+
|
|
|
+ vector<string> retval_msgs;
|
|
|
+ for (Json::Value i : retvalHdl.msg["messages"])
|
|
|
+ retval_msgs.push_back(i.asString());
|
|
|
+ EXPECT_EQ(retval_msgs, msgvec);
|
|
|
+
|
|
|
+ EXPECT_TRUE(cm.isLoggedIn());
|
|
|
+}
|
|
|
+
|
|
|
+TEST(testNotifications, Negative) {
|
|
|
+ FileManMock fm;
|
|
|
+ CmdManForTest cm(fm, dummyDebugPrint);
|
|
|
+ cm.initLoggedIn();
|
|
|
+
|
|
|
+ std::string cmd;
|
|
|
+ std::vector<std::string> args;
|
|
|
+ Json::Value root, messagesArr;
|
|
|
+ CmdMan::CmdRet retvalCmd;
|
|
|
+ CmdMan::CmdRet retvalHdl;
|
|
|
+
|
|
|
+ // prepare cmd/args/root
|
|
|
+ cmd = "notifications";
|
|
|
+ args = {};
|
|
|
+ root["command"] = "notifications";
|
|
|
+ root["accept"] = false;
|
|
|
+ root["error"] = "some very descriptive string";
|
|
|
+
|
|
|
+ // stick into cmdman
|
|
|
+ retvalCmd = cm.execute(cmd, args);
|
|
|
+ retvalHdl = cm.handle(root);
|
|
|
+
|
|
|
+ // check things
|
|
|
+ EXPECT_EQ(retvalCmd.type, CmdMan::send);
|
|
|
+ EXPECT_EQ(retvalCmd.msg["command"].asString(), "notifications");
|
|
|
+
|
|
|
+ EXPECT_EQ(retvalHdl.type, CmdMan::error);
|
|
|
+ EXPECT_EQ(retvalHdl.msg["command"].asString(), "notifications");
|
|
|
+ EXPECT_FALSE(retvalHdl.msg["accept"].asBool());
|
|
|
+ EXPECT_THAT(retvalHdl.msg["error"].asString(), testing::HasSubstr("some very descriptive string"));
|
|
|
+
|
|
|
+ EXPECT_TRUE(cm.isLoggedIn());
|
|
|
+}
|
|
|
+
|
|
|
+/* =====================================
|
|
|
+ * test for all commands that require a login
|
|
|
+ */
|
|
|
TEST(testCommandsWithRequiredLogin, NotLoggedInOrNotConnected) {
|
|
|
FileManMock fm;
|
|
|
CmdManForTest cm(fm, dummyDebugPrint);
|