|
@@ -1657,7 +1657,7 @@ TEST(testList, Positive) {
|
|
|
root["items"] = 92;
|
|
|
root["chunks"] = 2;
|
|
|
|
|
|
- EXPECT_CALL(fm, openList).WillOnce(testing::Return(true));
|
|
|
+ EXPECT_CALL(fm, openList(false)).WillOnce(testing::Return(true));
|
|
|
|
|
|
EXPECT_CALL(fm, cancelList).Times(0); // not called
|
|
|
|
|
@@ -1667,7 +1667,7 @@ TEST(testList, Positive) {
|
|
|
EXPECT_EQ(retvalCmd.type, CmdMan::send);
|
|
|
EXPECT_EQ(retvalCmd.msg["command"].asString(), "list");
|
|
|
|
|
|
- EXPECT_CALL(fm, isListing()).WillOnce(testing::Return(true));
|
|
|
+ EXPECT_CALL(fm, isListingSimple()).WillOnce(testing::Return(true));
|
|
|
EXPECT_CALL(fm, setListChunks(2));
|
|
|
|
|
|
retvalHdl = cm.handle(root);
|
|
@@ -1703,7 +1703,7 @@ TEST(testListdata, Positive_ChunksRemaining) {
|
|
|
root["names"] = namesArr;
|
|
|
|
|
|
EXPECT_CALL(fm, getListRemainingChunks).Times(2).WillRepeatedly(testing::Return(3));
|
|
|
- EXPECT_CALL(fm, isListing).Times(2).WillRepeatedly(testing::Return(true));
|
|
|
+ EXPECT_CALL(fm, isListingSimple).Times(2).WillRepeatedly(testing::Return(true));
|
|
|
|
|
|
EXPECT_CALL(fm, cancelList).Times(0); // not called
|
|
|
|
|
@@ -1715,7 +1715,7 @@ TEST(testListdata, Positive_ChunksRemaining) {
|
|
|
EXPECT_EQ(retvalCmd.msg["chunk"].asInt(), 3);
|
|
|
EXPECT_EQ(retvalCmd.msg["cancel"].asBool(), false);
|
|
|
|
|
|
- vector<string> vec{"blue.txt", "red.pdf", "green.sh", "yellow.tgz"};
|
|
|
+ vector<Json::Value> vec{Json::Value("blue.txt"), Json::Value("red.pdf"), Json::Value("green.sh"), Json::Value("yellow.tgz")};
|
|
|
EXPECT_CALL(fm, putListData(vec));
|
|
|
|
|
|
retvalHdl = cm.handle(root);
|
|
@@ -1747,7 +1747,7 @@ TEST(testListdata, Positive_LastChunk) {
|
|
|
root["names"] = namesArr;
|
|
|
|
|
|
EXPECT_CALL(fm, getListRemainingChunks).Times(2).WillRepeatedly(testing::Return(0));
|
|
|
- EXPECT_CALL(fm, isListing).Times(2).WillRepeatedly(testing::Return(true));
|
|
|
+ EXPECT_CALL(fm, isListingSimple).Times(2).WillRepeatedly(testing::Return(true));
|
|
|
|
|
|
EXPECT_CALL(fm, cancelList).Times(0); // not called
|
|
|
|
|
@@ -1759,10 +1759,10 @@ TEST(testListdata, Positive_LastChunk) {
|
|
|
EXPECT_EQ(retvalCmd.msg["chunk"].asInt(), 0);
|
|
|
EXPECT_EQ(retvalCmd.msg["cancel"].asBool(), false);
|
|
|
|
|
|
- vector<string> vec{"magenta.vcd"};
|
|
|
+ vector<Json::Value> vec{Json::Value("magenta.vcd")};
|
|
|
EXPECT_CALL(fm, putListData(vec));
|
|
|
EXPECT_CALL(fm, closeList);
|
|
|
- vector<string> allFiles{"blue.txt", "red.pdf", "green.sh", "yellow.tgz", "cyan.exe", "white", "black", "magenta.vcd"};
|
|
|
+ vector<Json::Value> allFiles{"blue.txt", "red.pdf", "green.sh", "yellow.tgz", "cyan.exe", "white", "black", "magenta.vcd"};
|
|
|
EXPECT_CALL(fm, getListData).WillOnce(testing::Return(allFiles));
|
|
|
|
|
|
retvalHdl = cm.handle(root);
|
|
@@ -1774,7 +1774,8 @@ TEST(testListdata, Positive_LastChunk) {
|
|
|
EXPECT_EQ(retvalHdl.type, CmdMan::print);
|
|
|
EXPECT_EQ(retvalHdl.msg["command"].asString(), "list");
|
|
|
EXPECT_TRUE(retvalHdl.msg["accept"].asBool());
|
|
|
- EXPECT_EQ(retval_msg_names, allFiles);
|
|
|
+ vector<string> allFilesStringVec{"blue.txt", "red.pdf", "green.sh", "yellow.tgz", "cyan.exe", "white", "black", "magenta.vcd"};
|
|
|
+ EXPECT_EQ(retval_msg_names, allFilesStringVec);
|
|
|
|
|
|
EXPECT_TRUE(cm.isLoggedIn());
|
|
|
}
|
|
@@ -1798,7 +1799,7 @@ TEST(testList, Negative_ListEmpty) {
|
|
|
root["items"] = 0;
|
|
|
|
|
|
// stick into cmdman and check things
|
|
|
- EXPECT_CALL(fm, openList).WillOnce(testing::Return(true));
|
|
|
+ EXPECT_CALL(fm, openList(false)).WillOnce(testing::Return(true));
|
|
|
retvalCmd = cm.execute(cmd, args);
|
|
|
|
|
|
EXPECT_EQ(retvalCmd.type, CmdMan::send);
|
|
@@ -1823,8 +1824,6 @@ TEST(testListdata, Negative) {
|
|
|
/* tests the handling of server reply only,
|
|
|
* initial request assumed as correct (tested in other tests) */
|
|
|
|
|
|
- std::string cmd;
|
|
|
- std::vector<std::string> args;
|
|
|
Json::Value root;
|
|
|
CmdMan::CmdRet retvalHdl;
|
|
|
|
|
@@ -1852,14 +1851,13 @@ TEST(testList, Negative_AlreadyListing) {
|
|
|
|
|
|
std::string cmd;
|
|
|
std::vector<std::string> args;
|
|
|
- Json::Value root;
|
|
|
CmdMan::CmdRet retvalCmd;
|
|
|
|
|
|
// prepare cmd/args
|
|
|
cmd = "list";
|
|
|
args = {};
|
|
|
|
|
|
- EXPECT_CALL(fm, openList).WillOnce(testing::Return(false));
|
|
|
+ EXPECT_CALL(fm, openList(false)).WillOnce(testing::Return(false));
|
|
|
|
|
|
EXPECT_CALL(fm, cancelList).Times(0); // not called
|
|
|
|
|
@@ -1879,8 +1877,6 @@ TEST(testList, Negative_NotListing_ServerRequest) {
|
|
|
CmdManForTest cm(fm, dummyDebugPrint);
|
|
|
cm.initLoggedIn();
|
|
|
|
|
|
- std::string cmd;
|
|
|
- std::vector<std::string> args;
|
|
|
Json::Value root, namesArr;
|
|
|
CmdMan::CmdRet retvalHdl;
|
|
|
|
|
@@ -1895,7 +1891,7 @@ TEST(testList, Negative_NotListing_ServerRequest) {
|
|
|
EXPECT_CALL(fm, putListData).Times(0);
|
|
|
EXPECT_CALL(fm, closeList).Times(0);
|
|
|
EXPECT_CALL(fm, getListData).Times(0);
|
|
|
- EXPECT_CALL(fm, isListing).WillOnce(testing::Return(false));
|
|
|
+ EXPECT_CALL(fm, isListingSimple).WillOnce(testing::Return(false));
|
|
|
|
|
|
retvalHdl = cm.handle(root);
|
|
|
|
|
@@ -1920,7 +1916,7 @@ TEST(testListdata, Negative_NotListing_UserRequest) {
|
|
|
cmd = "listdata";
|
|
|
args = {};
|
|
|
|
|
|
- EXPECT_CALL(fm, isListing).WillOnce(testing::Return(false));
|
|
|
+ EXPECT_CALL(fm, isListingSimple).WillOnce(testing::Return(false));
|
|
|
|
|
|
// stick into cmdman and check things
|
|
|
retvalCmd = cm.execute(cmd, args);
|
|
@@ -1949,6 +1945,7 @@ TEST(testListdata, Negative_NotListing_ServerRequest) {
|
|
|
root["names"] = namesArr;
|
|
|
|
|
|
EXPECT_CALL(fm, cancelList).Times(0);
|
|
|
+ EXPECT_CALL(fm, isListingSimple).WillOnce(testing::Return(false));
|
|
|
|
|
|
retvalHdl = cm.handle(root);
|
|
|
|
|
@@ -1960,6 +1957,364 @@ TEST(testListdata, Negative_NotListing_ServerRequest) {
|
|
|
EXPECT_TRUE(cm.isLoggedIn());
|
|
|
}
|
|
|
|
|
|
+/* =====================================
|
|
|
+ * tests for extendedlist[data]
|
|
|
+ */
|
|
|
+
|
|
|
+TEST(testExtendedlist, Positive) {
|
|
|
+ FileManMock fm;
|
|
|
+ CmdManForTest cm(fm, dummyDebugPrint);
|
|
|
+ cm.initLoggedIn();
|
|
|
+
|
|
|
+ std::string cmd;
|
|
|
+ std::vector<std::string> args;
|
|
|
+ Json::Value root;
|
|
|
+ CmdMan::CmdRet retvalCmd;
|
|
|
+ CmdMan::CmdRet retvalHdl;
|
|
|
+
|
|
|
+ // prepare root/cmd/args
|
|
|
+ cmd = "extendedlist";
|
|
|
+ args = {};
|
|
|
+ root["command"] = "extendedlist";
|
|
|
+ root["accept"] = true;
|
|
|
+ root["items"] = 92;
|
|
|
+ root["chunks"] = 2;
|
|
|
+
|
|
|
+ EXPECT_CALL(fm, openList(true)).WillOnce(testing::Return(true));
|
|
|
+
|
|
|
+ EXPECT_CALL(fm, cancelList).Times(0); // not called
|
|
|
+
|
|
|
+ // stick into cmdman and check things
|
|
|
+ retvalCmd = cm.execute(cmd, args);
|
|
|
+
|
|
|
+ EXPECT_EQ(retvalCmd.type, CmdMan::send);
|
|
|
+ EXPECT_EQ(retvalCmd.msg["command"].asString(), "extendedlist");
|
|
|
+
|
|
|
+ EXPECT_CALL(fm, isListingExtended()).WillOnce(testing::Return(true));
|
|
|
+ EXPECT_CALL(fm, setListChunks(2));
|
|
|
+
|
|
|
+ retvalHdl = cm.handle(root);
|
|
|
+
|
|
|
+ EXPECT_EQ(retvalHdl.type, CmdMan::send);
|
|
|
+ EXPECT_EQ(retvalHdl.msg["command"].asString(), "extendedlist");
|
|
|
+ EXPECT_TRUE(retvalHdl.msg["accept"].asBool());
|
|
|
+ EXPECT_EQ(retvalHdl.nextcommand, "extendedlistdata");
|
|
|
+
|
|
|
+ EXPECT_TRUE(cm.isLoggedIn());
|
|
|
+}
|
|
|
+
|
|
|
+TEST(testExtendedlistdata, Positive_ChunksRemaining) {
|
|
|
+ FileManMock fm;
|
|
|
+ CmdManForTest cm(fm, dummyDebugPrint);
|
|
|
+ cm.initLoggedIn();
|
|
|
+
|
|
|
+ std::string cmd;
|
|
|
+ std::vector<std::string> args;
|
|
|
+ Json::Value root, files, f1, f2, namesArr;
|
|
|
+ CmdMan::CmdRet retvalCmd;
|
|
|
+ CmdMan::CmdRet retvalHdl;
|
|
|
+
|
|
|
+ // prepare root/cmd/args
|
|
|
+ f1["name"] = "blue.txt";
|
|
|
+ f1["size"] = 42.0f;
|
|
|
+ f1["head"] = "some head 1";
|
|
|
+ files.append(f1);
|
|
|
+ f2["name"] = "green.pdf";
|
|
|
+ f2["size"] = 9.0f;
|
|
|
+ f2["head"] = "some head 2";
|
|
|
+ files.append(f2);
|
|
|
+
|
|
|
+ cmd = "extendedlistdata";
|
|
|
+ args = {};
|
|
|
+ root["command"] = "extendedlistdata";
|
|
|
+ root["cancel"] = false;
|
|
|
+ root["remaining"] = 3;
|
|
|
+ root["files"] = files;
|
|
|
+
|
|
|
+ EXPECT_CALL(fm, getListRemainingChunks).Times(2).WillRepeatedly(testing::Return(3));
|
|
|
+ EXPECT_CALL(fm, isListingExtended).Times(2).WillRepeatedly(testing::Return(true));
|
|
|
+
|
|
|
+ EXPECT_CALL(fm, cancelList).Times(0); // not called
|
|
|
+
|
|
|
+ // stick into cmdman and check things
|
|
|
+ retvalCmd = cm.execute(cmd, args);
|
|
|
+
|
|
|
+ EXPECT_EQ(retvalCmd.type, CmdMan::send);
|
|
|
+ EXPECT_EQ(retvalCmd.msg["command"].asString(), "extendedlistdata");
|
|
|
+ EXPECT_EQ(retvalCmd.msg["chunk"].asInt(), 3);
|
|
|
+ EXPECT_EQ(retvalCmd.msg["cancel"].asBool(), false);
|
|
|
+
|
|
|
+ vector<Json::Value> vec{f1, f2};
|
|
|
+ EXPECT_CALL(fm, putListData(vec));
|
|
|
+
|
|
|
+ retvalHdl = cm.handle(root);
|
|
|
+
|
|
|
+ EXPECT_EQ(retvalHdl.type, CmdMan::send);
|
|
|
+ EXPECT_EQ(retvalHdl.nextcommand, "extendedlistdata");
|
|
|
+
|
|
|
+ EXPECT_TRUE(cm.isLoggedIn());
|
|
|
+}
|
|
|
+
|
|
|
+TEST(testExtendedlistdata, Positive_LastChunk) {
|
|
|
+ FileManMock fm;
|
|
|
+ CmdManForTest cm(fm, dummyDebugPrint);
|
|
|
+ cm.initLoggedIn();
|
|
|
+
|
|
|
+ std::string cmd;
|
|
|
+ std::vector<std::string> args;
|
|
|
+ Json::Value root, files, f1, f2, f3, inputfile;
|
|
|
+ CmdMan::CmdRet retvalCmd;
|
|
|
+ CmdMan::CmdRet retvalHdl;
|
|
|
+
|
|
|
+ // prepare file json/root/cmd/args
|
|
|
+
|
|
|
+ inputfile["name"] = "magenta.vcd";
|
|
|
+ inputfile["size"] = 9000.001f;
|
|
|
+ inputfile["head"] = "some head 3";
|
|
|
+ files.append(inputfile);
|
|
|
+
|
|
|
+ cmd = "extendedlistdata";
|
|
|
+ args = {};
|
|
|
+ root["command"] = "extendedlistdata";
|
|
|
+ root["cancel"] = false;
|
|
|
+ root["remaining"] = 0;
|
|
|
+ root["files"] = files;
|
|
|
+
|
|
|
+ EXPECT_CALL(fm, getListRemainingChunks).Times(2).WillRepeatedly(testing::Return(0));
|
|
|
+ EXPECT_CALL(fm, isListingExtended).Times(2).WillRepeatedly(testing::Return(true));
|
|
|
+
|
|
|
+ EXPECT_CALL(fm, cancelList).Times(0); // not called
|
|
|
+
|
|
|
+ // stick into cmdman and check things
|
|
|
+ retvalCmd = cm.execute(cmd, args);
|
|
|
+
|
|
|
+ EXPECT_EQ(retvalCmd.type, CmdMan::send);
|
|
|
+ EXPECT_EQ(retvalCmd.msg["command"].asString(), "extendedlistdata");
|
|
|
+ EXPECT_EQ(retvalCmd.msg["chunk"].asInt(), 0);
|
|
|
+ EXPECT_EQ(retvalCmd.msg["cancel"].asBool(), false);
|
|
|
+
|
|
|
+ vector<Json::Value> vec{inputfile};
|
|
|
+ EXPECT_CALL(fm, putListData(vec));
|
|
|
+ EXPECT_CALL(fm, closeList);
|
|
|
+ // output of fileman
|
|
|
+ f1["name"] = "blue.txt";
|
|
|
+ f1["size"] = 42.0f;
|
|
|
+ f1["encrypted"] = "unencrypted";
|
|
|
+ f2["name"] = "green.pdf";
|
|
|
+ f2["size"] = 9.0f;
|
|
|
+ f2["encrypted"] = "decryptable";
|
|
|
+ f3["name"] = "magenta.vcd";
|
|
|
+ f3["size"] = 9000.001f;
|
|
|
+ f3["encrypted"] = "undecryptable";
|
|
|
+ vector<Json::Value> allFiles{f1, f2, f3};
|
|
|
+ EXPECT_CALL(fm, getListData).WillOnce(testing::Return(allFiles));
|
|
|
+
|
|
|
+ retvalHdl = cm.handle(root);
|
|
|
+
|
|
|
+ EXPECT_EQ(retvalHdl.type, CmdMan::print);
|
|
|
+ EXPECT_EQ(retvalHdl.msg["command"].asString(), "extendedlist");
|
|
|
+ EXPECT_TRUE(retvalHdl.msg["accept"].asBool());
|
|
|
+ EXPECT_EQ(retvalHdl.msg["files"][0]["name"].asString(), "blue.txt");
|
|
|
+ EXPECT_EQ(retvalHdl.msg["files"][0]["encrypted"].asString(), "unencrypted");
|
|
|
+ EXPECT_EQ(retvalHdl.msg["files"][0]["size"].asFloat(), 42.0f);
|
|
|
+ EXPECT_EQ(retvalHdl.msg["files"][1]["name"].asString(), "green.pdf");
|
|
|
+ EXPECT_EQ(retvalHdl.msg["files"][1]["encrypted"].asString(), "decryptable");
|
|
|
+ EXPECT_EQ(retvalHdl.msg["files"][1]["size"].asFloat(), 9.0f);
|
|
|
+ EXPECT_EQ(retvalHdl.msg["files"][2]["name"].asString(), "magenta.vcd");
|
|
|
+ EXPECT_EQ(retvalHdl.msg["files"][2]["encrypted"].asString(), "undecryptable");
|
|
|
+ EXPECT_EQ(retvalHdl.msg["files"][2]["size"].asFloat(), 9000.001f);
|
|
|
+
|
|
|
+ EXPECT_TRUE(cm.isLoggedIn());
|
|
|
+}
|
|
|
+
|
|
|
+TEST(testExtendedlist, Negative_ListEmpty) {
|
|
|
+ FileManMock fm;
|
|
|
+ CmdManForTest cm(fm, dummyDebugPrint);
|
|
|
+ cm.initLoggedIn();
|
|
|
+
|
|
|
+ std::string cmd;
|
|
|
+ std::vector<std::string> args;
|
|
|
+ Json::Value root;
|
|
|
+ CmdMan::CmdRet retvalCmd;
|
|
|
+ CmdMan::CmdRet retvalHdl;
|
|
|
+
|
|
|
+ // prepare root/cmd/args
|
|
|
+ cmd = "extendedlist";
|
|
|
+ args = {};
|
|
|
+ root["command"] = "extendedlist";
|
|
|
+ root["accept"] = true;
|
|
|
+ root["items"] = 0;
|
|
|
+
|
|
|
+ // stick into cmdman and check things
|
|
|
+ EXPECT_CALL(fm, openList(true)).WillOnce(testing::Return(true));
|
|
|
+ retvalCmd = cm.execute(cmd, args);
|
|
|
+
|
|
|
+ EXPECT_EQ(retvalCmd.type, CmdMan::send);
|
|
|
+ EXPECT_EQ(retvalCmd.msg["command"].asString(), "extendedlist");
|
|
|
+
|
|
|
+ EXPECT_CALL(fm, closeList);
|
|
|
+ retvalHdl = cm.handle(root);
|
|
|
+
|
|
|
+ EXPECT_EQ(retvalHdl.type, CmdMan::print);
|
|
|
+ EXPECT_EQ(retvalHdl.msg["command"].asString(), "extendedlist");
|
|
|
+ EXPECT_FALSE(retvalHdl.msg["accept"].asBool());
|
|
|
+ EXPECT_THAT(retvalHdl.msg["error"].asString(), testing::HasSubstr("There are no files stored on the server."));
|
|
|
+
|
|
|
+ EXPECT_TRUE(cm.isLoggedIn());
|
|
|
+}
|
|
|
+
|
|
|
+TEST(testExtendedlistdata, Negative) {
|
|
|
+ FileManMock fm;
|
|
|
+ CmdManForTest cm(fm, dummyDebugPrint);
|
|
|
+ cm.initLoggedIn();
|
|
|
+
|
|
|
+ /* tests the handling of server reply only,
|
|
|
+ * initial request assumed as correct (tested in other tests) */
|
|
|
+
|
|
|
+ Json::Value root;
|
|
|
+ CmdMan::CmdRet retvalHdl;
|
|
|
+
|
|
|
+ // prepare root/cmd/args
|
|
|
+ root["command"] = "extendedlistdata";
|
|
|
+ root["cancel"] = true;
|
|
|
+ root["error"] = "some foobar";
|
|
|
+
|
|
|
+ EXPECT_CALL(fm, cancelList);
|
|
|
+
|
|
|
+ retvalHdl = cm.handle(root);
|
|
|
+
|
|
|
+ EXPECT_EQ(retvalHdl.type, CmdMan::error);
|
|
|
+ EXPECT_EQ(retvalHdl.msg["command"].asString(), "extendedlist");
|
|
|
+ EXPECT_FALSE(retvalHdl.msg["accept"].asBool());
|
|
|
+ EXPECT_THAT(retvalHdl.msg["error"].asString(), testing::HasSubstr("some foobar"));
|
|
|
+
|
|
|
+ EXPECT_TRUE(cm.isLoggedIn());
|
|
|
+}
|
|
|
+
|
|
|
+TEST(testExtendedlist, Negative_AlreadyListing) {
|
|
|
+ FileManMock fm;
|
|
|
+ CmdManForTest cm(fm, dummyDebugPrint);
|
|
|
+ cm.initLoggedIn();
|
|
|
+
|
|
|
+ std::string cmd;
|
|
|
+ std::vector<std::string> args;
|
|
|
+ Json::Value root;
|
|
|
+ CmdMan::CmdRet retvalCmd;
|
|
|
+
|
|
|
+ // prepare cmd/args
|
|
|
+ cmd = "extendedlist";
|
|
|
+ args = {};
|
|
|
+
|
|
|
+ EXPECT_CALL(fm, openList(true)).WillOnce(testing::Return(false));
|
|
|
+
|
|
|
+ EXPECT_CALL(fm, cancelList).Times(0); // not called
|
|
|
+
|
|
|
+ // stick into cmdman and check things
|
|
|
+ retvalCmd = cm.execute(cmd, args);
|
|
|
+
|
|
|
+ EXPECT_EQ(retvalCmd.type, CmdMan::error);
|
|
|
+ EXPECT_EQ(retvalCmd.msg["command"].asString(), "extendedlist");
|
|
|
+ EXPECT_FALSE(retvalCmd.msg["accept"].asBool());
|
|
|
+ EXPECT_NE(retvalCmd.msg["error"].asString(), "");
|
|
|
+
|
|
|
+ EXPECT_TRUE(cm.isLoggedIn());
|
|
|
+}
|
|
|
+
|
|
|
+TEST(testExtendedlist, Negative_NotListing_ServerRequest) {
|
|
|
+ FileManMock fm;
|
|
|
+ CmdManForTest cm(fm, dummyDebugPrint);
|
|
|
+ cm.initLoggedIn();
|
|
|
+
|
|
|
+ std::string cmd;
|
|
|
+ std::vector<std::string> args;
|
|
|
+ Json::Value root, files, inputfile;
|
|
|
+ CmdMan::CmdRet retvalHdl;
|
|
|
+
|
|
|
+ // prepare root
|
|
|
+ inputfile["name"] = "magenta.vcd";
|
|
|
+ inputfile["size"] = 9000.001f;
|
|
|
+ inputfile["head"] = "some head 3";
|
|
|
+ files.append(inputfile);
|
|
|
+
|
|
|
+ root["command"] = "extendedlistdata";
|
|
|
+ root["cancel"] = false;
|
|
|
+ root["remaining"] = 0;
|
|
|
+ root["files"] = files;
|
|
|
+
|
|
|
+ EXPECT_CALL(fm, cancelList).Times(0);
|
|
|
+ EXPECT_CALL(fm, putListData).Times(0);
|
|
|
+ EXPECT_CALL(fm, closeList).Times(0);
|
|
|
+ EXPECT_CALL(fm, getListData).Times(0);
|
|
|
+ EXPECT_CALL(fm, isListingExtended).WillOnce(testing::Return(false));
|
|
|
+
|
|
|
+ retvalHdl = cm.handle(root);
|
|
|
+
|
|
|
+ EXPECT_EQ(retvalHdl.type, CmdMan::error);
|
|
|
+ EXPECT_EQ(retvalHdl.msg["command"].asString(), "extendedlist");
|
|
|
+ EXPECT_FALSE(retvalHdl.msg["accept"].asBool());
|
|
|
+ EXPECT_NE(retvalHdl.msg["error"].asString(), "");
|
|
|
+
|
|
|
+ EXPECT_TRUE(cm.isLoggedIn());
|
|
|
+}
|
|
|
+
|
|
|
+TEST(testExtendedistdata, Negative_NotListing_UserRequest) {
|
|
|
+ FileManMock fm;
|
|
|
+ CmdManForTest cm(fm, dummyDebugPrint);
|
|
|
+ cm.initLoggedIn();
|
|
|
+
|
|
|
+ std::string cmd;
|
|
|
+ std::vector<std::string> args;
|
|
|
+ CmdMan::CmdRet retvalCmd;
|
|
|
+
|
|
|
+ // prepare root/cmd/args
|
|
|
+ cmd = "extendedlistdata";
|
|
|
+ args = {};
|
|
|
+
|
|
|
+ EXPECT_CALL(fm, isListingExtended).WillOnce(testing::Return(false));
|
|
|
+
|
|
|
+ // stick into cmdman and check things
|
|
|
+ retvalCmd = cm.execute(cmd, args);
|
|
|
+
|
|
|
+ EXPECT_EQ(retvalCmd.type, CmdMan::error);
|
|
|
+ EXPECT_EQ(retvalCmd.msg["command"].asString(), "extendedlist");
|
|
|
+ EXPECT_NE(retvalCmd.msg["error"].asString(), "");
|
|
|
+ EXPECT_EQ(retvalCmd.msg["accept"].asBool(), false);
|
|
|
+}
|
|
|
+
|
|
|
+TEST(testExtendedlistdata, Negative_NotListing_ServerRequest) {
|
|
|
+ FileManMock fm;
|
|
|
+ CmdManForTest cm(fm, dummyDebugPrint);
|
|
|
+ cm.initLoggedIn();
|
|
|
+
|
|
|
+ std::string cmd;
|
|
|
+ std::vector<std::string> args;
|
|
|
+ Json::Value root, files, inputfile;
|
|
|
+ CmdMan::CmdRet retvalHdl;
|
|
|
+
|
|
|
+ // prepare root
|
|
|
+ inputfile["name"] = "magenta.vcd";
|
|
|
+ inputfile["size"] = 9000.001f;
|
|
|
+ inputfile["head"] = "some head 3";
|
|
|
+ files.append(inputfile);
|
|
|
+
|
|
|
+ root["command"] = "extendedlistdata";
|
|
|
+ root["cancel"] = false;
|
|
|
+ root["remaining"] = 0;
|
|
|
+ root["files"] = files;
|
|
|
+
|
|
|
+ EXPECT_CALL(fm, cancelList).Times(0);
|
|
|
+ EXPECT_CALL(fm, isListingExtended).WillOnce(testing::Return(false));
|
|
|
+
|
|
|
+ retvalHdl = cm.handle(root);
|
|
|
+
|
|
|
+ EXPECT_EQ(retvalHdl.type, CmdMan::error);
|
|
|
+ EXPECT_EQ(retvalHdl.msg["command"].asString(), "extendedlist");
|
|
|
+ EXPECT_FALSE(retvalHdl.msg["accept"].asBool());
|
|
|
+ EXPECT_NE(retvalHdl.msg["error"].asString(), "");
|
|
|
+
|
|
|
+ EXPECT_TRUE(cm.isLoggedIn());
|
|
|
+}
|
|
|
+
|
|
|
/* =====================================
|
|
|
* tests for deleteme
|
|
|
*/
|
|
@@ -2812,8 +3167,8 @@ TEST(testCommandsWithRequiredLogin, NotLoggedInOrNotConnected) {
|
|
|
CmdMan::CmdRet retval1, retval2, retval3;
|
|
|
|
|
|
// prepare cmd/args
|
|
|
- std::vector<std::string> cmds = {"put", "get", "list", "putdata", "getdata", "listdata",
|
|
|
- "head", "deletefile", "deleteme", "keyfile", "closekey", "extendedstatus"};
|
|
|
+ std::vector<std::string> cmds = {"put", "get", "list", "extendedlist", "putdata", "getdata", "listdata", "extendedlistdata",
|
|
|
+ "head", "deletefile", "deleteme", "keyfile", "closekey", "extendedstatus"};
|
|
|
// as every command works fine with too many args, we will simply pass three to all of them
|
|
|
std::vector<std::string> args = {"arg1", "arg2", "arg3"};
|
|
|
|