JsonCommanderTest.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. #include <gmock/gmock.h>
  2. #include <gtest/gtest.h>
  3. #include "../include/JsonCommander.h"
  4. #include "FileManagerMock.h"
  5. namespace {
  6. /* Version tests */
  7. TEST(testVersion, Positive) {
  8. FileManagerMock fileManager;
  9. JsonCommander jsonCommander(fileManager);
  10. const std::string versionString = "0.2";
  11. Json::Value version;
  12. version["version"] = versionString;
  13. JsonCommander::Response response = jsonCommander.testVersion(version);
  14. EXPECT_TRUE(response.action == JsonCommander::Action::send);
  15. EXPECT_TRUE(response.json["accept"].asBool());
  16. EXPECT_EQ(response.json["version"].asString(), versionString);
  17. }
  18. TEST(testVersion, Negative) {
  19. FileManagerMock fileManager;
  20. JsonCommander jsonCommander(fileManager);
  21. const std::string versionString = "0.1";
  22. Json::Value version;
  23. version["version"] = versionString;
  24. JsonCommander::Response response = jsonCommander.testVersion(version);
  25. EXPECT_TRUE(response.action == JsonCommander::Action::closeAndSend);
  26. EXPECT_FALSE(response.json["accept"].asBool());
  27. EXPECT_FALSE(response.json["version"].asString().compare(versionString) == 0);
  28. }
  29. /* Status tests */
  30. TEST(Status, Ok) {
  31. FileManagerMock fileManager;
  32. JsonCommander jsonCommander(fileManager);
  33. const std::string command = "status";
  34. Json::Value message;
  35. message["command"] = command;
  36. JsonCommander::Response response = jsonCommander.execute(message);
  37. EXPECT_TRUE(response.action == JsonCommander::Action::send);
  38. EXPECT_EQ(response.json["command"].asString(), command);
  39. EXPECT_EQ(response.json["response"].asString(), "ok");
  40. }
  41. TEST(Status, Downloading) {
  42. FileManagerMock fileManager;
  43. JsonCommander jsonCommander(fileManager);
  44. const std::string command = "status";
  45. Json::Value message;
  46. message["command"] = command;
  47. ON_CALL(fileManager, isDownloading()).WillByDefault(testing::Return(true));
  48. JsonCommander::Response response = jsonCommander.execute(message);
  49. EXPECT_TRUE(response.action == JsonCommander::Action::send);
  50. EXPECT_EQ(response.json["command"].asString(), command);
  51. EXPECT_EQ(response.json["response"].asString(), "download running");
  52. }
  53. TEST(Status, Uploading) {
  54. FileManagerMock fileManager;
  55. JsonCommander jsonCommander(fileManager);
  56. const std::string command = "status";
  57. Json::Value message;
  58. message["command"] = command;
  59. ON_CALL(fileManager, isUploading()).WillByDefault(testing::Return(true));
  60. JsonCommander::Response response = jsonCommander.execute(message);
  61. EXPECT_TRUE(response.action == JsonCommander::Action::send);
  62. EXPECT_EQ(response.json["command"].asString(), command);
  63. EXPECT_EQ(response.json["response"].asString(), "upload running");
  64. }
  65. TEST(Status, UploadingAndDownloading) {
  66. FileManagerMock fileManager;
  67. JsonCommander jsonCommander(fileManager);
  68. const std::string command = "status";
  69. Json::Value message;
  70. message["command"] = command;
  71. ON_CALL(fileManager, isDownloading()).WillByDefault(testing::Return(true));
  72. ON_CALL(fileManager, isUploading()).WillByDefault(testing::Return(true));
  73. JsonCommander::Response response = jsonCommander.execute(message);
  74. EXPECT_TRUE(response.action == JsonCommander::Action::send);
  75. EXPECT_EQ(response.json["command"].asString(), command);
  76. EXPECT_EQ(response.json["response"].asString(),
  77. "download and upload running");
  78. }
  79. /* Close tests */
  80. TEST(Close, Close) {
  81. FileManagerMock fileManager;
  82. JsonCommander jsonCommander(fileManager);
  83. const std::string command = "close";
  84. Json::Value message;
  85. message["command"] = command;
  86. JsonCommander::Response response = jsonCommander.execute(message);
  87. EXPECT_TRUE(response.action == JsonCommander::Action::closeAndSend);
  88. EXPECT_EQ(response.json["command"].asString(), command);
  89. EXPECT_EQ(response.json["response"].asString(), "bye");
  90. }
  91. /* Put tests */
  92. TEST(Put, Positive) {
  93. FileManagerMock fileManager;
  94. JsonCommander jsonCommander(fileManager);
  95. const std::string command = "put";
  96. const std::string filename = "cool.txt";
  97. Json::Value message;
  98. message["command"] = command;
  99. message["file"] = filename;
  100. message["size"] = 1337;
  101. message["chunks"] = 1;
  102. ON_CALL(fileManager, openPutFile(testing::_))
  103. .WillByDefault(testing::Return(true));
  104. JsonCommander::Response response = jsonCommander.execute(message);
  105. EXPECT_TRUE(response.action == JsonCommander::Action::send);
  106. EXPECT_EQ(response.json["command"].asString(), command);
  107. EXPECT_TRUE(response.json["accept"].asBool());
  108. EXPECT_EQ(response.json["file"].asString(), filename);
  109. EXPECT_EQ(response.json["error"].asString(), "");
  110. }
  111. TEST(Put, Negative) {
  112. FileManagerMock fileManager;
  113. JsonCommander jsonCommander(fileManager);
  114. const std::string command = "put";
  115. const std::string filename = "cool.txt";
  116. Json::Value message;
  117. message["command"] = command;
  118. message["file"] = filename;
  119. message["size"] = 1337;
  120. message["chunks"] = 1;
  121. ON_CALL(fileManager, openPutFile(testing::_))
  122. .WillByDefault(testing::Return(false));
  123. JsonCommander::Response response = jsonCommander.execute(message);
  124. EXPECT_TRUE(response.action == JsonCommander::Action::send);
  125. EXPECT_EQ(response.json["command"].asString(), command);
  126. EXPECT_FALSE(response.json["accept"].asBool());
  127. EXPECT_EQ(response.json["file"].asString(), filename);
  128. EXPECT_TRUE(response.json["error"].asString().length() > 0);
  129. }
  130. /* Putdata tests */
  131. TEST(Putdata, Positive) {
  132. FileManagerMock fileManager;
  133. JsonCommander jsonCommander(fileManager);
  134. /* start with put */
  135. std::string command = "put";
  136. const std::string filename = "cool.txt";
  137. Json::Value message;
  138. message["command"] = command;
  139. message["file"] = filename;
  140. message["size"] = 1337;
  141. const int chunks = 3;
  142. message["chunks"] = chunks;
  143. ON_CALL(fileManager, openPutFile(testing::_))
  144. .WillByDefault(testing::Return(true));
  145. JsonCommander::Response response = jsonCommander.execute(message);
  146. EXPECT_TRUE(response.action == JsonCommander::Action::send);
  147. EXPECT_EQ(response.json["command"].asString(), command);
  148. EXPECT_TRUE(response.json["accept"].asBool());
  149. EXPECT_EQ(response.json["file"].asString(), filename);
  150. EXPECT_EQ(response.json["error"].asString(), "");
  151. /* putdata */
  152. command = "putdata";
  153. ON_CALL(fileManager, isUploading()).WillByDefault(testing::Return(true));
  154. ON_CALL(fileManager, getPutBaseFileName())
  155. .WillByDefault(testing::Return(filename));
  156. for (int remaining = chunks - 1; remaining >= 0; remaining--) {
  157. message = Json::Value();
  158. message["command"] = command;
  159. message["file"] = filename;
  160. message["data"] = "MTMzNw==";
  161. message["remaining"] = remaining;
  162. message["cancel"] = false;
  163. response = jsonCommander.execute(message);
  164. EXPECT_TRUE(response.action == JsonCommander::Action::send);
  165. EXPECT_EQ(response.json["command"].asString(), command);
  166. EXPECT_FALSE(response.json["cancel"].asBool());
  167. EXPECT_EQ(response.json["received"].asInt(), remaining);
  168. EXPECT_EQ(response.json["file"].asString(), filename);
  169. EXPECT_EQ(response.json["error"].asString(), "");
  170. }
  171. }
  172. TEST(Putdata, Cancel) {
  173. FileManagerMock fileManager;
  174. JsonCommander jsonCommander(fileManager);
  175. /* start with put */
  176. std::string command = "put";
  177. const std::string filename = "cool.txt";
  178. Json::Value message;
  179. message["command"] = command;
  180. message["file"] = filename;
  181. message["size"] = 1337;
  182. const int chunks = 3;
  183. message["chunks"] = chunks;
  184. ON_CALL(fileManager, openPutFile(testing::_))
  185. .WillByDefault(testing::Return(true));
  186. JsonCommander::Response response = jsonCommander.execute(message);
  187. EXPECT_TRUE(response.action == JsonCommander::Action::send);
  188. EXPECT_EQ(response.json["command"].asString(), command);
  189. EXPECT_TRUE(response.json["accept"].asBool());
  190. EXPECT_EQ(response.json["file"].asString(), filename);
  191. EXPECT_EQ(response.json["error"].asString(), "");
  192. /* putdata */
  193. command = "putdata";
  194. ON_CALL(fileManager, isUploading()).WillByDefault(testing::Return(true));
  195. ON_CALL(fileManager, getPutBaseFileName())
  196. .WillByDefault(testing::Return(filename));
  197. int remaining = chunks - 1;
  198. message = Json::Value();
  199. message["command"] = command;
  200. message["file"] = filename;
  201. message["data"] = "MTMzNw==";
  202. message["remaining"] = remaining;
  203. message["cancel"] = false;
  204. response = jsonCommander.execute(message);
  205. EXPECT_TRUE(response.action == JsonCommander::Action::send);
  206. EXPECT_EQ(response.json["command"].asString(), command);
  207. EXPECT_FALSE(response.json["cancel"].asBool());
  208. EXPECT_EQ(response.json["received"].asInt(), remaining);
  209. EXPECT_EQ(response.json["file"].asString(), filename);
  210. EXPECT_EQ(response.json["error"].asString(), "");
  211. // cancel transfer
  212. message = Json::Value();
  213. message["command"] = command;
  214. message["file"] = filename;
  215. message["data"] = "MTMzNw==";
  216. message["remaining"] = --remaining;
  217. message["cancel"] = true;
  218. response = jsonCommander.execute(message);
  219. EXPECT_TRUE(response.action == JsonCommander::Action::send);
  220. EXPECT_EQ(response.json["command"].asString(), command);
  221. EXPECT_TRUE(response.json["cancel"].asBool());
  222. EXPECT_EQ(response.json["received"].asInt(), remaining);
  223. EXPECT_EQ(response.json["file"].asString(), filename);
  224. EXPECT_EQ(response.json["error"].asString(), "");
  225. }
  226. TEST(Putdata, WrongRemaining) {
  227. FileManagerMock fileManager;
  228. JsonCommander jsonCommander(fileManager);
  229. /* start with put */
  230. std::string command = "put";
  231. const std::string filename = "cool.txt";
  232. Json::Value message;
  233. message["command"] = command;
  234. message["file"] = filename;
  235. message["size"] = 1337;
  236. const int chunks = 3;
  237. message["chunks"] = chunks;
  238. ON_CALL(fileManager, openPutFile(testing::_))
  239. .WillByDefault(testing::Return(true));
  240. JsonCommander::Response response = jsonCommander.execute(message);
  241. EXPECT_TRUE(response.action == JsonCommander::Action::send);
  242. EXPECT_EQ(response.json["command"].asString(), command);
  243. EXPECT_TRUE(response.json["accept"].asBool());
  244. EXPECT_EQ(response.json["file"].asString(), filename);
  245. EXPECT_EQ(response.json["error"].asString(), "");
  246. /* putdata */
  247. command = "putdata";
  248. ON_CALL(fileManager, isUploading()).WillByDefault(testing::Return(true));
  249. ON_CALL(fileManager, getPutBaseFileName())
  250. .WillByDefault(testing::Return(filename));
  251. int remaining = chunks - 1;
  252. message = Json::Value();
  253. message["command"] = command;
  254. message["file"] = filename;
  255. message["data"] = "MTMzNw==";
  256. message["remaining"] = remaining;
  257. message["cancel"] = false;
  258. response = jsonCommander.execute(message);
  259. EXPECT_TRUE(response.action == JsonCommander::Action::send);
  260. EXPECT_EQ(response.json["command"].asString(), command);
  261. EXPECT_FALSE(response.json["cancel"].asBool());
  262. EXPECT_EQ(response.json["received"].asInt(), remaining);
  263. EXPECT_EQ(response.json["file"].asString(), filename);
  264. EXPECT_EQ(response.json["error"].asString(), "");
  265. message = Json::Value();
  266. // skip remaining=1 and provoke an error
  267. remaining = 0;
  268. message = Json::Value();
  269. message["command"] = command;
  270. message["file"] = filename;
  271. message["data"] = "MTMzNw==";
  272. message["remaining"] = remaining;
  273. message["cancel"] = false;
  274. response = jsonCommander.execute(message);
  275. EXPECT_TRUE(response.action == JsonCommander::Action::send);
  276. EXPECT_EQ(response.json["command"].asString(), command);
  277. EXPECT_TRUE(response.json["cancel"].asBool());
  278. EXPECT_EQ(response.json["received"].asInt(), remaining);
  279. EXPECT_EQ(response.json["file"].asString(), filename);
  280. EXPECT_TRUE(response.json["error"].asString().length() > 0);
  281. }
  282. /* Get tests */
  283. TEST(Get, Positive) {
  284. FileManagerMock fileManager;
  285. JsonCommander jsonCommander(fileManager);
  286. const std::string command = "get";
  287. const std::string filename = "cool.txt";
  288. Json::Value message;
  289. message["command"] = command;
  290. message["file"] = filename;
  291. EXPECT_CALL(fileManager, openGetFile(testing::_, testing::_))
  292. .WillOnce(testing::DoAll(testing::SetArgReferee<1, int>(3),
  293. testing::Return(true)));
  294. JsonCommander::Response response = jsonCommander.execute(message);
  295. EXPECT_TRUE(response.action == JsonCommander::Action::send);
  296. EXPECT_EQ(response.json["command"].asString(), command);
  297. EXPECT_TRUE(response.json["accept"].asBool());
  298. EXPECT_EQ(response.json["file"].asString(), filename);
  299. EXPECT_TRUE(response.json["chunks"].asInt() > 0);
  300. EXPECT_EQ(response.json["error"].asString(), "");
  301. }
  302. TEST(Get, Negative) {
  303. FileManagerMock fileManager;
  304. JsonCommander jsonCommander(fileManager);
  305. const std::string command = "get";
  306. const std::string filename = "cool.txt";
  307. Json::Value message;
  308. message["command"] = command;
  309. message["file"] = filename;
  310. EXPECT_CALL(fileManager, openGetFile(testing::_, testing::_))
  311. .WillOnce(testing::Return(false));
  312. JsonCommander::Response response = jsonCommander.execute(message);
  313. EXPECT_TRUE(response.action == JsonCommander::Action::send);
  314. EXPECT_EQ(response.json["command"].asString(), command);
  315. EXPECT_FALSE(response.json["accept"].asBool());
  316. EXPECT_EQ(response.json["file"].asString(), filename);
  317. EXPECT_EQ(response.json["chunks"].asInt(), -1);
  318. EXPECT_TRUE(response.json["error"].asString().length() > 0);
  319. }
  320. /* Getdata tests */
  321. TEST(Getdata, Positive) {
  322. FileManagerMock fileManager;
  323. JsonCommander jsonCommander(fileManager);
  324. std::string command = "get";
  325. const std::string filename = "cool.txt";
  326. Json::Value message;
  327. message["command"] = command;
  328. message["file"] = filename;
  329. const int chunks = 3;
  330. EXPECT_CALL(fileManager, openGetFile(testing::_, testing::_))
  331. .WillOnce(testing::DoAll(testing::SetArgReferee<1, int>(chunks),
  332. testing::Return(true)));
  333. JsonCommander::Response response = jsonCommander.execute(message);
  334. EXPECT_TRUE(response.action == JsonCommander::Action::send);
  335. EXPECT_EQ(response.json["command"].asString(), command);
  336. EXPECT_TRUE(response.json["accept"].asBool());
  337. EXPECT_EQ(response.json["file"].asString(), filename);
  338. EXPECT_EQ(response.json["chunks"].asInt(), chunks);
  339. EXPECT_EQ(response.json["error"].asString(), "");
  340. /* getdata */
  341. command = "getdata";
  342. ON_CALL(fileManager, isDownloading()).WillByDefault(testing::Return(true));
  343. ON_CALL(fileManager, getGetBaseFileName())
  344. .WillByDefault(testing::Return(filename));
  345. std::vector<char> data;
  346. data.push_back('1');
  347. data.push_back('3');
  348. data.push_back('3');
  349. data.push_back('7');
  350. ON_CALL(fileManager, readGet()).WillByDefault(testing::Return(data));
  351. for (int remaining = chunks - 1; remaining >= 0; remaining--) {
  352. message = Json::Value();
  353. message["command"] = command;
  354. message["file"] = filename;
  355. message["chunk"] = remaining;
  356. message["cancel"] = false;
  357. response = jsonCommander.execute(message);
  358. EXPECT_TRUE(response.action == JsonCommander::Action::send);
  359. EXPECT_EQ(response.json["command"].asString(), command);
  360. EXPECT_FALSE(response.json["cancel"].asBool());
  361. EXPECT_EQ(response.json["remaining"].asInt(), remaining);
  362. EXPECT_EQ(response.json["file"].asString(), filename);
  363. EXPECT_EQ(response.json["data"].asString(), "MTMzNw==");
  364. EXPECT_EQ(response.json["error"].asString(), "");
  365. }
  366. }
  367. TEST(Getdata, Cancle) {
  368. FileManagerMock fileManager;
  369. JsonCommander jsonCommander(fileManager);
  370. std::string command = "get";
  371. const std::string filename = "cool.txt";
  372. Json::Value message;
  373. message["command"] = command;
  374. message["file"] = filename;
  375. const int chunks = 3;
  376. EXPECT_CALL(fileManager, openGetFile(testing::_, testing::_))
  377. .WillOnce(testing::DoAll(testing::SetArgReferee<1, int>(chunks),
  378. testing::Return(true)));
  379. JsonCommander::Response response = jsonCommander.execute(message);
  380. EXPECT_TRUE(response.action == JsonCommander::Action::send);
  381. EXPECT_EQ(response.json["command"].asString(), command);
  382. EXPECT_TRUE(response.json["accept"].asBool());
  383. EXPECT_EQ(response.json["file"].asString(), filename);
  384. EXPECT_EQ(response.json["chunks"].asInt(), chunks);
  385. EXPECT_EQ(response.json["error"].asString(), "");
  386. /* getdata */
  387. command = "getdata";
  388. ON_CALL(fileManager, isDownloading()).WillByDefault(testing::Return(true));
  389. ON_CALL(fileManager, getGetBaseFileName())
  390. .WillByDefault(testing::Return(filename));
  391. std::vector<char> data;
  392. data.push_back('1');
  393. data.push_back('3');
  394. data.push_back('3');
  395. data.push_back('7');
  396. ON_CALL(fileManager, readGet()).WillByDefault(testing::Return(data));
  397. int remaining = chunks - 1;
  398. message = Json::Value();
  399. message["command"] = command;
  400. message["file"] = filename;
  401. message["chunk"] = remaining;
  402. message["cancel"] = false;
  403. response = jsonCommander.execute(message);
  404. EXPECT_TRUE(response.action == JsonCommander::Action::send);
  405. EXPECT_EQ(response.json["command"].asString(), command);
  406. EXPECT_FALSE(response.json["cancel"].asBool());
  407. EXPECT_EQ(response.json["remaining"].asInt(), remaining);
  408. EXPECT_EQ(response.json["file"].asString(), filename);
  409. EXPECT_EQ(response.json["data"].asString(), "MTMzNw==");
  410. EXPECT_EQ(response.json["error"].asString(), "");
  411. // set cancel to true
  412. message = Json::Value();
  413. message["command"] = command;
  414. message["file"] = filename;
  415. message["chunk"] = --remaining;
  416. message["cancel"] = true;
  417. response = jsonCommander.execute(message);
  418. EXPECT_TRUE(response.action == JsonCommander::Action::send);
  419. EXPECT_EQ(response.json["command"].asString(), command);
  420. EXPECT_TRUE(response.json["cancel"].asBool());
  421. EXPECT_EQ(response.json["remaining"].asInt(), remaining);
  422. EXPECT_EQ(response.json["file"].asString(), filename);
  423. EXPECT_EQ(response.json["data"].asString(), "");
  424. EXPECT_EQ(response.json["error"].asString(), "");
  425. }
  426. TEST(Getdata, WrongChunk) {
  427. FileManagerMock fileManager;
  428. JsonCommander jsonCommander(fileManager);
  429. std::string command = "get";
  430. const std::string filename = "cool.txt";
  431. Json::Value message;
  432. message["command"] = command;
  433. message["file"] = filename;
  434. const int chunks = 3;
  435. EXPECT_CALL(fileManager, openGetFile(testing::_, testing::_))
  436. .WillOnce(testing::DoAll(testing::SetArgReferee<1, int>(chunks),
  437. testing::Return(true)));
  438. JsonCommander::Response response = jsonCommander.execute(message);
  439. EXPECT_TRUE(response.action == JsonCommander::Action::send);
  440. EXPECT_EQ(response.json["command"].asString(), command);
  441. EXPECT_TRUE(response.json["accept"].asBool());
  442. EXPECT_EQ(response.json["file"].asString(), filename);
  443. EXPECT_EQ(response.json["chunks"].asInt(), chunks);
  444. EXPECT_EQ(response.json["error"].asString(), "");
  445. /* getdata */
  446. command = "getdata";
  447. ON_CALL(fileManager, isDownloading()).WillByDefault(testing::Return(true));
  448. ON_CALL(fileManager, getGetBaseFileName())
  449. .WillByDefault(testing::Return(filename));
  450. std::vector<char> data;
  451. data.push_back('1');
  452. data.push_back('3');
  453. data.push_back('3');
  454. data.push_back('7');
  455. ON_CALL(fileManager, readGet()).WillByDefault(testing::Return(data));
  456. int remaining = chunks - 1;
  457. message = Json::Value();
  458. message["command"] = command;
  459. message["file"] = filename;
  460. message["chunk"] = remaining;
  461. message["cancel"] = false;
  462. response = jsonCommander.execute(message);
  463. EXPECT_TRUE(response.action == JsonCommander::Action::send);
  464. EXPECT_EQ(response.json["command"].asString(), command);
  465. EXPECT_FALSE(response.json["cancel"].asBool());
  466. EXPECT_EQ(response.json["remaining"].asInt(), remaining);
  467. EXPECT_EQ(response.json["file"].asString(), filename);
  468. EXPECT_EQ(response.json["data"].asString(), "MTMzNw==");
  469. EXPECT_EQ(response.json["error"].asString(), "");
  470. // skip chunk=0
  471. remaining = 0;
  472. message = Json::Value();
  473. message["command"] = command;
  474. message["file"] = filename;
  475. message["chunk"] = remaining;
  476. message["cancel"] = false;
  477. response = jsonCommander.execute(message);
  478. EXPECT_TRUE(response.action == JsonCommander::Action::send);
  479. EXPECT_EQ(response.json["command"].asString(), command);
  480. EXPECT_TRUE(response.json["cancel"].asBool());
  481. EXPECT_EQ(response.json["remaining"].asInt(), remaining);
  482. EXPECT_EQ(response.json["file"].asString(), filename);
  483. EXPECT_EQ(response.json["data"].asString(), "");
  484. EXPECT_TRUE(response.json["error"].asString().length() > 0);
  485. }
  486. } // namespace