summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBSolonenko <BSolonenko@luxoft.com>2018-04-17 16:23:53 +0300
committerIra Lytvynenko (GitHub) <ILytvynenko@luxoft.com>2018-05-24 13:15:46 +0300
commit8838c28ed711008ae24be8a313e97c5dec677825 (patch)
tree45a6fcc57c073974e0eba77b0d9b976028a30f21
parent767575366af311bbf33c26bd7ab74040f68890b7 (diff)
downloadsdl_core-8838c28ed711008ae24be8a313e97c5dec677825.tar.gz
Fix UT after implementation of Expandable Design
-rw-r--r--src/components/application_manager/src/commands/mobile/on_system_request_notification.cc1
-rw-r--r--src/components/application_manager/src/commands/mobile/system_request.cc1
-rw-r--r--src/components/application_manager/test/commands/CMakeLists.txt1
-rw-r--r--src/components/application_manager/test/commands/mobile/register_app_interface_request_test.cc6
-rw-r--r--src/components/application_manager/test/policy_handler_test.cc6
-rw-r--r--src/components/include/test/application_manager/policies/mock_policy_handler_interface.h12
-rw-r--r--src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h7
-rw-r--r--src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h8
-rw-r--r--src/components/policy/policy_regular/test/sql_pt_representation_test.cc10
9 files changed, 50 insertions, 2 deletions
diff --git a/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc b/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc
index 78ab666056..f06012893e 100644
--- a/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc
+++ b/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc
@@ -36,6 +36,7 @@
#include "application_manager/commands/mobile/on_system_request_notification.h"
#include "interfaces/MOBILE_API.h"
#include "utils/file_system.h"
+#include "policy/policy_table/enums.h"
#include "application_manager/application_manager.h"
#include "application_manager/policies/policy_handler_interface.h"
diff --git a/src/components/application_manager/src/commands/mobile/system_request.cc b/src/components/application_manager/src/commands/mobile/system_request.cc
index c081510e7c..f0331d0ced 100644
--- a/src/components/application_manager/src/commands/mobile/system_request.cc
+++ b/src/components/application_manager/src/commands/mobile/system_request.cc
@@ -41,6 +41,7 @@ Copyright (c) 2013, Ford Motor Company
#include "application_manager/policies/policy_handler_interface.h"
#include "interfaces/MOBILE_API.h"
#include "utils/file_system.h"
+#include "policy/policy_table/enums.h"
#include "formatters/CFormatterJsonBase.h"
#include "json/json.h"
#include "utils/helpers.h"
diff --git a/src/components/application_manager/test/commands/CMakeLists.txt b/src/components/application_manager/test/commands/CMakeLists.txt
index 8dafc16471..be236fdb49 100644
--- a/src/components/application_manager/test/commands/CMakeLists.txt
+++ b/src/components/application_manager/test/commands/CMakeLists.txt
@@ -65,6 +65,7 @@ set(LIBRARIES
AMMobileCommandsLibrary
connectionHandler
jsoncpp
+ Policy
)
create_cotired_test("commands_test" "${SOURCES}" "${LIBRARIES}" )
diff --git a/src/components/application_manager/test/commands/mobile/register_app_interface_request_test.cc b/src/components/application_manager/test/commands/mobile/register_app_interface_request_test.cc
index b7a004f199..2e3e5fbfdf 100644
--- a/src/components/application_manager/test/commands/mobile/register_app_interface_request_test.cc
+++ b/src/components/application_manager/test/commands/mobile/register_app_interface_request_test.cc
@@ -161,6 +161,12 @@ class RegisterAppInterfaceRequestTest
.WillByDefault(ReturnRef(kDummyDiagModes));
ON_CALL(mock_policy_handler_, GetAppRequestTypes(_))
.WillByDefault(Return(std::vector<std::string>()));
+ ON_CALL(mock_policy_handler_, GetAppRequestTypeState(_))
+ .WillByDefault(Return(policy::RequestType::State::EMPTY));
+ ON_CALL(mock_policy_handler_, GetAppRequestSubTypes(_))
+ .WillByDefault(Return(std::vector<std::string>()));
+ ON_CALL(mock_policy_handler_, GetAppRequestSubTypeState(_))
+ .WillByDefault(Return(policy::RequestSubType::State::EMPTY));
ON_CALL(mock_policy_handler_, GetUserConsentForDevice(_))
.WillByDefault(Return(policy::DeviceConsent::kDeviceAllowed));
ON_CALL(app_mngr_, GetDeviceTransportType(_))
diff --git a/src/components/application_manager/test/policy_handler_test.cc b/src/components/application_manager/test/policy_handler_test.cc
index d9e1cefa01..215f17a0e0 100644
--- a/src/components/application_manager/test/policy_handler_test.cc
+++ b/src/components/application_manager/test/policy_handler_test.cc
@@ -1377,8 +1377,12 @@ TEST_F(PolicyHandlerTest, IsRequestTypeAllowed) {
mobile_apis::RequestType::eType type =
mobile_apis::RequestType::eType::EMERGENCY;
+
+ EXPECT_CALL(*mock_policy_manager_, GetAppRequestTypesState(kPolicyAppId_))
+ .WillOnce(Return(policy::RequestType::State::AVAILABLE));
+
EXPECT_CALL(*mock_policy_manager_, GetAppRequestTypes(kPolicyAppId_))
- .WillOnce(Return(std::vector<std::string>()));
+ .WillOnce(Return(std::vector<std::string>({"HTTP"})));
// Act
policy_handler_.IsRequestTypeAllowed(kPolicyAppId_, type);
}
diff --git a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h
index 931fd6cfb4..dfd537c678 100644
--- a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h
+++ b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h
@@ -197,6 +197,18 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface {
MOCK_CONST_METHOD2(IsRequestTypeAllowed,
bool(const std::string& policy_app_id,
mobile_apis::RequestType::eType type));
+ MOCK_CONST_METHOD2(IsRequestSubTypeAllowed,
+ bool(const std::string& policy_app_id,
+ const std::string& request_subtype));
+ MOCK_CONST_METHOD1(
+ GetAppRequestTypeState,
+ policy::RequestType::State(const std::string& policy_app_id));
+ MOCK_CONST_METHOD1(
+ GetAppRequestSubTypeState,
+ policy::RequestSubType::State(const std::string& policy_app_id));
+ MOCK_CONST_METHOD1(
+ GetAppRequestSubTypes,
+ const std::vector<std::string>(const std::string& policy_app_id));
MOCK_CONST_METHOD1(
GetAppRequestTypes,
const std::vector<std::string>(const std::string& policy_app_id));
diff --git a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h
index ed3a5088c1..cf20dcb666 100644
--- a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h
+++ b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h
@@ -214,6 +214,13 @@ class MockCacheManagerInterface : public CacheManagerInterface {
MOCK_METHOD2(OnDeviceSwitching,
void(const std::string& device_id_from,
const std::string& device_id_to));
+ MOCK_CONST_METHOD2(GetAppRequestSubTypes,
+ void(const std::string& policy_app_id,
+ std::vector<std::string>& request_subtypes));
+ MOCK_CONST_METHOD1(GetAppRequestTypesState,
+ RequestType::State(const std::string& policy_app_id));
+ MOCK_CONST_METHOD1(GetAppRequestSubTypesState,
+ RequestSubType::State(const std::string& policy_app_id));
};
} // namespace policy_test
diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h
index 82012b83c7..0b8823d307 100644
--- a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h
+++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h
@@ -226,6 +226,14 @@ class MockPolicyManager : public PolicyManager {
MOCK_METHOD2(OnDeviceSwitching,
void(const std::string& device_id_from,
const std::string& device_id_to));
+
+ MOCK_CONST_METHOD1(
+ GetAppRequestSubTypes,
+ const std::vector<std::string>(const std::string& policy_app_id));
+ MOCK_CONST_METHOD1(GetAppRequestTypesState,
+ RequestType::State(const std::string& policy_app_id));
+ MOCK_CONST_METHOD1(GetAppRequestSubTypesState,
+ RequestSubType::State(const std::string& policy_app_id));
};
} // namespace policy_manager_test
diff --git a/src/components/policy/policy_regular/test/sql_pt_representation_test.cc b/src/components/policy/policy_regular/test/sql_pt_representation_test.cc
index fd83c82b1a..a5f3741331 100644
--- a/src/components/policy/policy_regular/test/sql_pt_representation_test.cc
+++ b/src/components/policy/policy_regular/test/sql_pt_representation_test.cc
@@ -289,6 +289,7 @@ class SQLPTRepresentationTest : public SQLPTRepresentation,
app_policies["default"]["default_hmi"] = Json::Value("FULL");
app_policies["default"]["keep_context"] = Json::Value(true);
app_policies["default"]["steal_focus"] = Json::Value(true);
+ app_policies["default"]["RequestType"] = Json::Value(Json::arrayValue);
app_policies["pre_DataConsent"] = Json::Value(Json::objectValue);
app_policies["pre_DataConsent"]["memory_kb"] = Json::Value(40);
@@ -300,6 +301,9 @@ class SQLPTRepresentationTest : public SQLPTRepresentation,
app_policies["pre_DataConsent"]["is_revoked"] = Json::Value(false);
app_policies["pre_DataConsent"]["keep_context"] = Json::Value(true);
app_policies["pre_DataConsent"]["steal_focus"] = Json::Value(true);
+ app_policies["pre_DataConsent"]["RequestType"] =
+ Json::Value(Json::arrayValue);
+
app_policies["1234"] = Json::Value(Json::objectValue);
app_policies["1234"]["memory_kb"] = Json::Value(150);
app_policies["1234"]["heart_beat_timeout_ms"] = Json::Value(200);
@@ -310,6 +314,8 @@ class SQLPTRepresentationTest : public SQLPTRepresentation,
app_policies["1234"]["is_revoked"] = Json::Value(true);
app_policies["1234"]["keep_context"] = Json::Value(false);
app_policies["1234"]["steal_focus"] = Json::Value(false);
+ app_policies["1234"]["RequestType"] = Json::Value(Json::arrayValue);
+
app_policies["device"] = Json::Value(Json::objectValue);
app_policies["device"]["groups"] = Json::Value(Json::arrayValue);
app_policies["device"]["groups"][0] = Json::Value("default");
@@ -420,7 +426,9 @@ TEST_F(SQLPTRepresentationTest,
ASSERT_EQ(0, dbms->FetchOneInt(query_select));
ASSERT_TRUE(reps->RefreshDB());
// Check PT structure destroyed and tables number is 0
- const int32_t total_tables_number = 28;
+
+ // There are 29 tables in the database, now.
+ const int32_t total_tables_number = 29;
ASSERT_EQ(total_tables_number, dbms->FetchOneInt(query_select));
const char* query_select_count_of_iap_buffer_full =
"SELECT `count_of_iap_buffer_full` FROM `usage_and_error_count`";