summaryrefslogtreecommitdiff
path: root/src/components/application_manager/test/commands
diff options
context:
space:
mode:
authorAnton Hrytsevich (GitHub) <AGritsevich@users.noreply.github.com>2016-11-09 17:07:44 +0200
committerGitHub <noreply@github.com>2016-11-09 17:07:44 +0200
commitc7b7cd3ac5a72fb67820c5a76c779517bd5a1f98 (patch)
tree25f1f042c91fb2c0b193a48c5066ff4806d4b815 /src/components/application_manager/test/commands
parentddef86df90c0f33b244419c1a9d7aa36d8a9322b (diff)
downloadsdl_core-c7b7cd3ac5a72fb67820c5a76c779517bd5a1f98.tar.gz
Change rule of sending Rejected code according to CRS (#954)
* Chanage SDL code according to CRS Related-issue: [APPLINK-29148](https://adc.luxoft.com/jira/browse/APPLINK-29148)
Diffstat (limited to 'src/components/application_manager/test/commands')
-rw-r--r--src/components/application_manager/test/commands/mobile/CMakeLists.txt4
-rw-r--r--src/components/application_manager/test/commands/mobile/delete_file_test.cc154
-rw-r--r--src/components/application_manager/test/commands/mobile/put_file_test.cc92
3 files changed, 250 insertions, 0 deletions
diff --git a/src/components/application_manager/test/commands/mobile/CMakeLists.txt b/src/components/application_manager/test/commands/mobile/CMakeLists.txt
index 31c8503573..387e4685ba 100644
--- a/src/components/application_manager/test/commands/mobile/CMakeLists.txt
+++ b/src/components/application_manager/test/commands/mobile/CMakeLists.txt
@@ -51,6 +51,7 @@ set (SOURCES
${COMMANDS_TEST_SOURCE_DIR}/mobile/alert_request_test.cc
${COMMANDS_TEST_SOURCE_DIR}/mobile/add_sub_menu_request_test.cc
${COMMANDS_TEST_SOURCE_DIR}/mobile/delete_sub_menu_test.cc
+ ${COMMANDS_TEST_SOURCE_DIR}/mobile/delete_file_test.cc
${COMMANDS_TEST_SOURCE_DIR}/mobile/set_media_clock_timer_test.cc
${COMMANDS_TEST_SOURCE_DIR}/mobile/set_global_properties_test.cc
${COMMANDS_TEST_SOURCE_DIR}/mobile/set_app_icon_test.cc
@@ -59,6 +60,9 @@ set (SOURCES
${COMMANDS_TEST_SOURCE_DIR}/mobile/scrollable_message_test.cc
${COMMANDS_TEST_SOURCE_DIR}/mobile/perform_audio_pass_thru_test.cc
${COMMANDS_TEST_SOURCE_DIR}/mobile/end_audio_pass_thru_request_test.cc
+ ${COMMANDS_TEST_SOURCE_DIR}/mobile/list_files_request_test.cc
+ ${COMMANDS_TEST_SOURCE_DIR}/mobile/put_file_test.cc
+ ${COMMANDS_TEST_SOURCE_DIR}/mobile/subscribe_button_request_test.cc
)
set(LIBRARIES
diff --git a/src/components/application_manager/test/commands/mobile/delete_file_test.cc b/src/components/application_manager/test/commands/mobile/delete_file_test.cc
new file mode 100644
index 0000000000..1b7064585e
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/delete_file_test.cc
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 2016, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdint.h>
+#include <vector>
+#include <string>
+#include <map>
+
+#include "mobile/delete_file_request.h"
+#include "mobile/delete_file_response.h"
+
+#include "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "utils/file_system.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/commands/commands_test.h"
+#include "application_manager/commands/command_request_test.h"
+#include "application_manager/application.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/event_engine/event.h"
+#include "application_manager/mock_hmi_capabilities.h"
+#include "application_manager/policies/mock_policy_handler_interface.h"
+#include "application_manager/mock_application_manager_settings.h"
+
+#include "interfaces/MOBILE_API.h"
+#include "application_manager/policies/policy_handler_interface.h"
+#include "application_manager/policies/policy_handler.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+namespace delete_file {
+
+using ::testing::_;
+using ::testing::Test;
+using ::testing::Return;
+using ::testing::ReturnRef;
+namespace am = ::application_manager;
+using am::commands::DeleteFileRequest;
+using am::commands::DeleteFileResponse;
+using am::commands::MessageSharedPtr;
+using am::event_engine::Event;
+using am::MockMessageHelper;
+
+typedef SharedPtr<DeleteFileRequest> DeleteFileRequestPtr;
+typedef SharedPtr<DeleteFileResponse> DeleteFileResponsePtr;
+typedef NiceMock<
+ ::test::components::application_manager_test::MockHMICapabilities>
+ MockHMICapabilities;
+
+ACTION_TEMPLATE(SetArgPointer,
+ HAS_1_TEMPLATE_PARAMS(int, k),
+ AND_1_VALUE_PARAMS(vec)) {
+ *std::tr1::get<k>(args) = *vec;
+}
+
+namespace {
+const uint32_t kConnectionKey = 2u;
+const uint32_t kCorrelationId = 10u;
+const int32_t kMenuId = 5;
+} // namespace
+
+class DeleteFileRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ protected:
+ void SetUp() OVERRIDE {
+ message_ = CreateMessage();
+ command_ = CreateCommand<DeleteFileRequest>(message_);
+ mock_app_ = CreateMockApp();
+ }
+
+ DeleteFileRequestPtr command_;
+ MessageSharedPtr message_;
+ MockAppPtr mock_app_;
+};
+
+TEST_F(DeleteFileRequestTest, Run_HMILevelNone_UNSUCCESS) {
+ EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_));
+ EXPECT_CALL(*mock_app_, hmi_level())
+ .WillOnce(Return(am::mobile_api::HMILevel::HMI_NONE));
+
+ EXPECT_CALL(app_mngr_, get_settings())
+ .WillOnce(ReturnRef(app_mngr_settings_));
+ const uint32_t num = 0;
+ EXPECT_CALL(app_mngr_settings_, delete_file_in_none())
+ .WillOnce(ReturnRef(num));
+ EXPECT_CALL(*mock_app_, delete_file_in_none_count()).WillOnce(Return(1));
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::REJECTED),
+ am::commands::Command::CommandOrigin::ORIGIN_SDL));
+
+ command_->Run();
+}
+
+TEST_F(DeleteFileRequestTest, Run_InvalidFile_UNSUCCESS) {
+ const std::string file_name = "test_file.txt";
+ (*message_)[am::strings::msg_params][am::strings::sync_file_name] = file_name;
+
+ EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_));
+ EXPECT_CALL(*mock_app_, hmi_level())
+ .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL));
+
+ EXPECT_CALL(app_mngr_, get_settings())
+ .WillOnce(ReturnRef(app_mngr_settings_));
+ const std::string kFullFilePath = file_system::CurrentWorkingDirectory();
+ EXPECT_CALL(app_mngr_settings_, app_storage_folder())
+ .WillOnce(ReturnRef(kFullFilePath));
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::REJECTED),
+ am::commands::Command::CommandOrigin::ORIGIN_SDL));
+ command_->Run();
+}
+
+} // namespace delete_file
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/put_file_test.cc b/src/components/application_manager/test/commands/mobile/put_file_test.cc
new file mode 100644
index 0000000000..cbabb4d2ec
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/put_file_test.cc
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2016, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdint.h>
+#include <string>
+
+#include "gtest/gtest.h"
+
+#include "interfaces/MOBILE_API.h"
+#include "application_manager/commands/commands_test.h"
+#include "application_manager/commands/command_request_test.h"
+#include "mobile/put_file_response.h"
+#include "mobile/put_file_request.h"
+#include "utils/make_shared.h"
+#include "smart_objects/smart_object.h"
+
+#include "application_manager/mock_application.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+namespace put_file {
+
+using namespace application_manager;
+
+using ::testing::Return;
+using ::testing::_;
+
+class PutFilesRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {};
+
+TEST_F(PutFilesRequestTest, Run_TooManyHmiNone_UNSUCCESS) {
+ MockAppPtr app(CreateMockApp());
+ SharedPtr<commands::PutFileRequest> command(
+ CreateCommand<commands::PutFileRequest>());
+
+ ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
+ ON_CALL(*app, hmi_level())
+ .WillByDefault(Return(mobile_apis::HMILevel::HMI_NONE));
+
+ const uint32_t put_files_in_none_allowed = 1u;
+ const uint32_t put_files_in_none_count = 2u;
+
+ ON_CALL(app_mngr_, get_settings())
+ .WillByDefault(ReturnRef(app_mngr_settings_));
+ ON_CALL(app_mngr_settings_, put_file_in_none())
+ .WillByDefault(ReturnRef(put_files_in_none_allowed));
+ ON_CALL(*app, put_file_in_none_count())
+ .WillByDefault(Return(put_files_in_none_count));
+
+ MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command)));
+ EXPECT_EQ(mobile_apis::Result::REJECTED,
+ static_cast<mobile_apis::Result::eType>(
+ (*result_msg)[am::strings::msg_params][am::strings::result_code]
+ .asInt()));
+}
+
+} // namespace put_file
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test