diff options
author | Kozoriz <kozorizandriy@gmail.com> | 2016-03-24 08:39:52 +0200 |
---|---|---|
committer | Kozoriz <kozorizandriy@gmail.com> | 2016-03-31 17:54:09 +0300 |
commit | e80be1d22c0110a8f8533ee49b5237497c810242 (patch) | |
tree | bf108c248b64d65bfd596bd8bc4f89cf0424a7fe /src | |
parent | 8546ee2ace59a5c6ff456e42cb039da1555128a7 (diff) | |
download | sdl_core-e80be1d22c0110a8f8533ee49b5237497c810242.tar.gz |
Profile test correctives
Diffstat (limited to 'src')
-rw-r--r-- | src/components/config_profile/test/profile_test.cc | 162 |
1 files changed, 77 insertions, 85 deletions
diff --git a/src/components/config_profile/test/profile_test.cc b/src/components/config_profile/test/profile_test.cc index 1bcd28b83e..2aad634108 100644 --- a/src/components/config_profile/test/profile_test.cc +++ b/src/components/config_profile/test/profile_test.cc @@ -47,10 +47,10 @@ using namespace ::profile; class ProfileTest : public ::testing::Test { protected: virtual void SetUp() { - profile::Profile::destroy(); + Profile::destroy(); } virtual void TearDown() { - profile::Profile::destroy(); + Profile::destroy(); } }; @@ -58,7 +58,7 @@ class ProfileTest : public ::testing::Test { TEST_F(ProfileTest, SingletonProfile) { Profile::instance(); EXPECT_TRUE(Profile::exists()); - profile::Profile::destroy(); + Profile::destroy(); EXPECT_FALSE(Profile::exists()); } @@ -67,17 +67,17 @@ TEST_F(ProfileTest, UpdateConfigWithDefaultFile) { uint32_t thread_min_stack_size = threads::Thread::kMinStackSize; EXPECT_EQ(thread_min_stack_size, Profile::instance()->thread_min_stack_size()); - EXPECT_FALSE(profile::Profile::instance()->enable_policy()); + EXPECT_FALSE(Profile::instance()->enable_policy()); std::string vr_help_title_ = ""; EXPECT_EQ(vr_help_title_, Profile::instance()->vr_help_title()); EXPECT_EQ("smartDeviceLink.ini", Profile::instance()->config_file_name()); - profile::Profile::instance()->UpdateValues(); + Profile::instance()->UpdateValues(); // Value was updated thread_min_stack_size = 20480; EXPECT_EQ(thread_min_stack_size, Profile::instance()->thread_min_stack_size()); - EXPECT_TRUE(profile::Profile::instance()->enable_policy()); + EXPECT_TRUE(Profile::instance()->enable_policy()); vr_help_title_ = "Available Vr Commands List"; EXPECT_EQ(vr_help_title_, Profile::instance()->vr_help_title()); } @@ -87,7 +87,7 @@ TEST_F(ProfileTest, SetConfigFileWithoutCallUpdate) { uint32_t thread_min_stack_size = threads::Thread::kMinStackSize; EXPECT_EQ(thread_min_stack_size, Profile::instance()->thread_min_stack_size()); - EXPECT_FALSE(profile::Profile::instance()->enable_policy()); + EXPECT_FALSE(Profile::instance()->enable_policy()); std::string vr_help_title_ = ""; EXPECT_EQ(vr_help_title_, Profile::instance()->vr_help_title()); EXPECT_EQ("smartDeviceLink.ini", Profile::instance()->config_file_name()); @@ -99,7 +99,7 @@ TEST_F(ProfileTest, SetConfigFileWithoutCallUpdate) { thread_min_stack_size = 20480; EXPECT_EQ(thread_min_stack_size, Profile::instance()->thread_min_stack_size()); - EXPECT_TRUE(profile::Profile::instance()->enable_policy()); + EXPECT_TRUE(Profile::instance()->enable_policy()); vr_help_title_ = "Available Vr Commands List"; EXPECT_EQ(vr_help_title_, Profile::instance()->vr_help_title()); } @@ -118,7 +118,7 @@ TEST_F(ProfileTest, SetConfigFileWithUpdate) { Profile::instance()->thread_min_stack_size()); // Update config file again - profile::Profile::instance()->UpdateValues(); + Profile::instance()->UpdateValues(); // Value should be the same EXPECT_EQ(thread_min_stack_size, @@ -131,7 +131,7 @@ TEST_F(ProfileTest, UpdateManyTimesDefaultFile) { EXPECT_EQ("smartDeviceLink.ini", Profile::instance()->config_file_name()); // Update config many times for (int i = 0; i < 10; i++) { - profile::Profile::instance()->UpdateValues(); + Profile::instance()->UpdateValues(); } } @@ -152,7 +152,7 @@ TEST_F(ProfileTest, UpdateIntValues) { Profile::instance()->thread_min_stack_size()); // Update config file again - profile::Profile::instance()->UpdateValues(); + Profile::instance()->UpdateValues(); // Values are same EXPECT_EQ(thread_min_stack_size, Profile::instance()->thread_min_stack_size()); @@ -168,7 +168,7 @@ TEST_F(ProfileTest, UpdateIntValues) { Profile::instance()->thread_min_stack_size()); // Update config file again - profile::Profile::instance()->UpdateValues(); + Profile::instance()->UpdateValues(); EXPECT_EQ("smartDeviceLink_test.ini", Profile::instance()->config_file_name()); @@ -189,22 +189,22 @@ TEST_F(ProfileTest, UpdateIntValues) { TEST_F(ProfileTest, UpdateBoolValues) { // Default values EXPECT_EQ("smartDeviceLink.ini", Profile::instance()->config_file_name()); - EXPECT_TRUE(profile::Profile::instance()->launch_hmi()); - EXPECT_FALSE(profile::Profile::instance()->enable_policy()); + EXPECT_TRUE(Profile::instance()->launch_hmi()); + EXPECT_FALSE(Profile::instance()->enable_policy()); // Set config file Profile::instance()->config_file_name("smartDeviceLink.ini"); // Check values - EXPECT_TRUE(profile::Profile::instance()->launch_hmi()); - EXPECT_TRUE(profile::Profile::instance()->enable_policy()); - EXPECT_FALSE(profile::Profile::instance()->is_redecoding_enabled()); + EXPECT_TRUE(Profile::instance()->launch_hmi()); + EXPECT_TRUE(Profile::instance()->enable_policy()); + EXPECT_FALSE(Profile::instance()->is_redecoding_enabled()); // Update config file again - profile::Profile::instance()->UpdateValues(); + Profile::instance()->UpdateValues(); // Values are same - EXPECT_TRUE(profile::Profile::instance()->launch_hmi()); - EXPECT_TRUE(profile::Profile::instance()->enable_policy()); - EXPECT_FALSE(profile::Profile::instance()->is_redecoding_enabled()); + EXPECT_TRUE(Profile::instance()->launch_hmi()); + EXPECT_TRUE(Profile::instance()->enable_policy()); + EXPECT_FALSE(Profile::instance()->is_redecoding_enabled()); // Change config file Profile::instance()->config_file_name("smartDeviceLink_test.ini"); @@ -212,53 +212,48 @@ TEST_F(ProfileTest, UpdateBoolValues) { Profile::instance()->config_file_name()); // Parameters after updating - EXPECT_FALSE(profile::Profile::instance()->launch_hmi()); - EXPECT_FALSE(profile::Profile::instance()->enable_policy()); - EXPECT_TRUE(profile::Profile::instance()->is_redecoding_enabled()); + EXPECT_FALSE(Profile::instance()->launch_hmi()); + EXPECT_FALSE(Profile::instance()->enable_policy()); + EXPECT_TRUE(Profile::instance()->is_redecoding_enabled()); // Update config file - profile::Profile::instance()->UpdateValues(); + Profile::instance()->UpdateValues(); // Parameters are same - EXPECT_FALSE(profile::Profile::instance()->launch_hmi()); - EXPECT_FALSE(profile::Profile::instance()->enable_policy()); - EXPECT_TRUE(profile::Profile::instance()->is_redecoding_enabled()); + EXPECT_FALSE(Profile::instance()->launch_hmi()); + EXPECT_FALSE(Profile::instance()->enable_policy()); + EXPECT_TRUE(Profile::instance()->is_redecoding_enabled()); } TEST_F(ProfileTest, UpdateStringValue) { // Default values - std::string config_folder = ""; + std::string recording_file_name = "record.wav"; std::string tts_delimiter_ = ""; std::string vr_help_title_ = ""; std::string server_address = "127.0.0.1"; - std::string app_resourse_folder = ""; - EXPECT_EQ(config_folder, Profile::instance()->app_resourse_folder()); + std::string app_resource_folder = ""; + EXPECT_EQ(app_resource_folder, Profile::instance()->app_resource_folder()); EXPECT_EQ(server_address, profile::Profile::instance()->server_address()); Profile::instance()->config_file_name("smartDeviceLink.ini"); EXPECT_EQ("smartDeviceLink.ini", Profile::instance()->config_file_name()); // Check values - config_folder = file_system::CurrentWorkingDirectory(); - EXPECT_EQ(config_folder, Profile::instance()->app_resourse_folder()); + app_resource_folder = file_system::CurrentWorkingDirectory(); + EXPECT_EQ(app_resource_folder, Profile::instance()->app_resource_folder()); tts_delimiter_ = ","; EXPECT_EQ(tts_delimiter_, Profile::instance()->tts_delimiter()); vr_help_title_ = "Available Vr Commands List"; EXPECT_EQ(vr_help_title_, Profile::instance()->vr_help_title()); - EXPECT_EQ(server_address, profile::Profile::instance()->server_address()); - app_resourse_folder = file_system::CurrentWorkingDirectory(); - EXPECT_EQ(app_resourse_folder, Profile::instance()->app_resourse_folder()); - // Update config file - profile::Profile::instance()->UpdateValues(); + Profile::instance()->UpdateValues(); // Values are the same - EXPECT_EQ(config_folder, Profile::instance()->app_resourse_folder()); + EXPECT_EQ(app_resource_folder, Profile::instance()->app_resource_folder()); EXPECT_EQ(tts_delimiter_, Profile::instance()->tts_delimiter()); EXPECT_EQ(vr_help_title_, Profile::instance()->vr_help_title()); - EXPECT_EQ(server_address, profile::Profile::instance()->server_address()); - EXPECT_EQ(app_resourse_folder, Profile::instance()->app_resourse_folder()); + EXPECT_EQ(server_address, Profile::instance()->server_address()); } TEST_F(ProfileTest, UpdateInt_ValueAppearsInFileTwice) { @@ -284,7 +279,7 @@ TEST_F(ProfileTest, UpdateBool_ValueAppearsInFileTwice) { Profile::instance()->config_file_name()); // Update config file // First value is false - EXPECT_FALSE(profile::Profile::instance()->is_mixing_audio_supported()); + EXPECT_FALSE(Profile::instance()->is_mixing_audio_supported()); } TEST_F(ProfileTest, UpdateVectorOfString_ValueAppearsInFileTwice) { @@ -328,7 +323,7 @@ TEST_F(ProfileTest, UpdatePairsValue) { EXPECT_EQ(value, Profile::instance()->get_vehicle_data_frequency()); // Update config file - profile::Profile::instance()->UpdateValues(); + Profile::instance()->UpdateValues(); EXPECT_EQ(value, Profile::instance()->get_vehicle_data_frequency()); } @@ -351,7 +346,7 @@ TEST_F(ProfileTest, PairsValueEmpty) { EXPECT_EQ(value, Profile::instance()->read_did_frequency()); // Update config file - profile::Profile::instance()->UpdateValues(); + Profile::instance()->UpdateValues(); // Values are same EXPECT_EQ(value, Profile::instance()->read_did_frequency()); } @@ -369,7 +364,7 @@ TEST_F(ProfileTest, CharValueInPairInsteadOfInt) { EXPECT_EQ(value, Profile::instance()->get_vehicle_data_frequency()); // Update config file - profile::Profile::instance()->UpdateValues(); + Profile::instance()->UpdateValues(); // Values are same EXPECT_EQ(value, Profile::instance()->get_vehicle_data_frequency()); } @@ -385,7 +380,7 @@ TEST_F(ProfileTest, EmptyValuesInPair) { EXPECT_EQ(value, Profile::instance()->get_vehicle_data_frequency()); // Update config file - profile::Profile::instance()->UpdateValues(); + Profile::instance()->UpdateValues(); // Values are same EXPECT_EQ(value, Profile::instance()->get_vehicle_data_frequency()); } @@ -406,7 +401,7 @@ TEST_F(ProfileTest, IntInsteadOfPair) { EXPECT_EQ(value, Profile::instance()->start_stream_retry_amount()); // Update config file - profile::Profile::instance()->UpdateValues(); + Profile::instance()->UpdateValues(); // Values are same EXPECT_EQ(value, Profile::instance()->start_stream_retry_amount()); } @@ -426,7 +421,7 @@ TEST_F(ProfileTest, WrongIntValue) { EXPECT_EQ(heart_beat_timeout, Profile::instance()->heart_beat_timeout()); // Update config file - profile::Profile::instance()->UpdateValues(); + Profile::instance()->UpdateValues(); EXPECT_EQ(heart_beat_timeout, Profile::instance()->heart_beat_timeout()); } @@ -445,7 +440,7 @@ TEST_F(ProfileTest, WrongMaxIntValue) { EXPECT_EQ(maxvalue, Profile::instance()->max_cmd_id()); // Update config file - profile::Profile::instance()->UpdateValues(); + Profile::instance()->UpdateValues(); EXPECT_EQ(maxvalue, Profile::instance()->max_cmd_id()); } @@ -468,7 +463,7 @@ TEST_F(ProfileTest, WrongMinIntValue) { EXPECT_EQ(server_port, Profile::instance()->server_port()); // Update config file - profile::Profile::instance()->UpdateValues(); + Profile::instance()->UpdateValues(); // Default value should be lefted EXPECT_EQ(minvalue, Profile::instance()->thread_min_stack_size()); @@ -499,7 +494,7 @@ TEST_F(ProfileTest, CheckCorrectValueWhenOtherValueInvalid) { Profile::instance()->thread_min_stack_size()); // Update config file - profile::Profile::instance()->UpdateValues(); + Profile::instance()->UpdateValues(); // In file the number is bigger than can be, default value should be lefted EXPECT_EQ(maxvalue, Profile::instance()->max_cmd_id()); @@ -517,7 +512,7 @@ TEST_F(ProfileTest, PairsValueInsteadOfInt) { EXPECT_EQ(list_files_in_none, Profile::instance()->list_files_in_none()); // Update config file - profile::Profile::instance()->UpdateValues(); + Profile::instance()->UpdateValues(); // Values are same EXPECT_EQ(list_files_in_none, Profile::instance()->list_files_in_none()); } @@ -525,9 +520,9 @@ TEST_F(ProfileTest, PairsValueInsteadOfInt) { TEST_F(ProfileTest, StringValueIncludeSlashesAndRussianLetters) { // Default values std::string config_folder = ""; - EXPECT_EQ(config_folder, Profile::instance()->app_resourse_folder()); + EXPECT_EQ(config_folder, Profile::instance()->app_resource_folder()); std::string tts_delimiter_ = ""; - std::string app_resourse_folder = ""; + std::string app_resource_folder = ""; std::string app_storage_folder = ""; std::string current_dir = file_system::CurrentWorkingDirectory(); @@ -536,25 +531,22 @@ TEST_F(ProfileTest, StringValueIncludeSlashesAndRussianLetters) { Profile::instance()->config_file_name()); // Check values - config_folder = "///"; - EXPECT_EQ(config_folder, Profile::instance()->app_config_folder()); tts_delimiter_ = "coma and point"; EXPECT_EQ(tts_delimiter_, Profile::instance()->tts_delimiter()); std::string server_address = "127.0.0.1 + слово"; EXPECT_EQ(server_address, profile::Profile::instance()->server_address()); - app_resourse_folder = "/new folder/"; - EXPECT_EQ(current_dir+app_resourse_folder, Profile::instance()->app_resourse_folder()); + app_resource_folder = "/new folder/"; + EXPECT_EQ(current_dir+app_resource_folder, Profile::instance()->app_resource_folder()); app_storage_folder = "/\" \""; EXPECT_EQ(current_dir+app_storage_folder, Profile::instance()->app_storage_folder()); // Update config file - profile::Profile::instance()->UpdateValues(); + Profile::instance()->UpdateValues(); // Values are the same - EXPECT_EQ(config_folder, Profile::instance()->app_config_folder()); EXPECT_EQ(tts_delimiter_, Profile::instance()->tts_delimiter()); EXPECT_EQ(server_address, profile::Profile::instance()->server_address()); - EXPECT_EQ(current_dir+app_resourse_folder, Profile::instance()->app_resourse_folder()); + EXPECT_EQ(current_dir+app_resource_folder, Profile::instance()->app_resource_folder()); } TEST_F(ProfileTest, StringUpperBoundValue) { @@ -577,7 +569,7 @@ TEST_F(ProfileTest, StringUpperBoundValue) { "0/0/0/1/2345678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHIJKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012345678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHIJKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012345678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHIJKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012345678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHIJKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012345678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHIJKL+MNO|PQR~STU{}WXY[]Z,01234567890abc"; EXPECT_EQ(recording_file_name, Profile::instance()->recording_file_name()); // Update config file - profile::Profile::instance()->UpdateValues(); + Profile::instance()->UpdateValues(); // Values are the same EXPECT_EQ(vr_help_title, Profile::instance()->vr_help_title()); EXPECT_EQ(recording_file_name, Profile::instance()->recording_file_name()); @@ -586,15 +578,15 @@ TEST_F(ProfileTest, StringUpperBoundValue) { TEST_F(ProfileTest, CapitalLetterInBoolValue) { // Default values EXPECT_EQ("smartDeviceLink.ini", Profile::instance()->config_file_name()); - EXPECT_TRUE(profile::Profile::instance()->launch_hmi()); - EXPECT_FALSE(profile::Profile::instance()->enable_policy()); + EXPECT_TRUE(Profile::instance()->launch_hmi()); + EXPECT_FALSE(Profile::instance()->enable_policy()); // Set config file Profile::instance()->config_file_name("smartDeviceLink.ini"); // Check values - EXPECT_TRUE(profile::Profile::instance()->launch_hmi()); - EXPECT_TRUE(profile::Profile::instance()->enable_policy()); - EXPECT_FALSE(profile::Profile::instance()->is_redecoding_enabled()); + EXPECT_TRUE(Profile::instance()->launch_hmi()); + EXPECT_TRUE(Profile::instance()->enable_policy()); + EXPECT_FALSE(Profile::instance()->is_redecoding_enabled()); // Change config file Profile::instance()->config_file_name("smartDeviceLink_invalid_boolean.ini"); @@ -603,11 +595,11 @@ TEST_F(ProfileTest, CapitalLetterInBoolValue) { // Parameters after updating // Parameter launch_hmi = True - EXPECT_FALSE(profile::Profile::instance()->launch_hmi()); + EXPECT_FALSE(Profile::instance()->launch_hmi()); // EnablePolicy = TRUE - EXPECT_FALSE(profile::Profile::instance()->enable_policy()); + EXPECT_FALSE(Profile::instance()->enable_policy()); // EnableRedecoding = FALSE - EXPECT_FALSE(profile::Profile::instance()->is_redecoding_enabled()); + EXPECT_FALSE(Profile::instance()->is_redecoding_enabled()); } TEST_F(ProfileTest, CheckReadStringValue) { @@ -616,16 +608,16 @@ TEST_F(ProfileTest, CheckReadStringValue) { EXPECT_EQ("smartDeviceLink_test.ini", Profile::instance()->config_file_name()); - std::string app_resourse_folder_; + std::string app_storage_folder_; profile::Profile::instance()->ReadStringValue( - &app_resourse_folder_, file_system::CurrentWorkingDirectory().c_str(), - "MAIN", "AppResourceFolder"); + &app_storage_folder_, file_system::CurrentWorkingDirectory().c_str(), + "MAIN", "AppStorageFolder"); // Get default value - EXPECT_EQ(app_resourse_folder_, file_system::CurrentWorkingDirectory()); + EXPECT_EQ("storage", app_storage_folder_); // Get value from file std::string server_address; - profile::Profile::instance()->ReadStringValue(&server_address, "", "HMI", + Profile::instance()->ReadStringValue(&server_address, "", "HMI", "ServerAddress"); EXPECT_EQ("127.0.0.1", server_address); } @@ -637,17 +629,17 @@ TEST_F(ProfileTest, CheckReadBoolValue) { Profile::instance()->config_file_name()); bool enable_policy; - profile::Profile::instance()->ReadBoolValue(&enable_policy, false, "Policy", + Profile::instance()->ReadBoolValue(&enable_policy, false, "Policy", "EnablePolicy"); EXPECT_FALSE(enable_policy); // Change config back - profile::Profile::destroy(); + Profile::destroy(); EXPECT_EQ("smartDeviceLink.ini", Profile::instance()->config_file_name()); //get default value bool launch_hmi; - profile::Profile::instance()->ReadBoolValue(&launch_hmi, true, "HMI", + Profile::instance()->ReadBoolValue(&launch_hmi, true, "HMI", "LaunchHMI"); EXPECT_TRUE(launch_hmi); } @@ -659,7 +651,7 @@ TEST_F(ProfileTest, CheckReadIntValue) { Profile::instance()->config_file_name()); int server_port = 0; - profile::Profile::instance()->ReadIntValue(&server_port, 0, "HMI", + Profile::instance()->ReadIntValue(&server_port, 0, "HMI", "ServerPort"); EXPECT_EQ(8088, server_port); @@ -673,7 +665,7 @@ TEST_F(ProfileTest, CheckIntContainer) { bool isread = false; std::vector<int> diagmodes_list = - profile::Profile::instance()->ReadIntContainer("MAIN", + Profile::instance()->ReadIntContainer("MAIN", "SupportedDiagModes", &isread); EXPECT_TRUE(isread); @@ -703,12 +695,12 @@ TEST_F(ProfileTest, CheckVectorContainer) { Profile::instance()->config_file_name()); // Get diag_modes after updating - const std::vector<uint32_t> &diag_modes = profile::Profile::instance() + const std::vector<uint32_t> &diag_modes = Profile::instance() ->supported_diag_modes(); bool isread = false; std::vector<int> diagmodes_list = - profile::Profile::instance()->ReadIntContainer("MAIN", + Profile::instance()->ReadIntContainer("MAIN", "SupportedDiagModes", &isread); EXPECT_TRUE(isread); @@ -736,7 +728,7 @@ TEST_F(ProfileTest, CheckStringContainer) { Profile::instance()->config_file_name()); bool isread = false; - std::vector < std::string > diagmodes_list = profile::Profile::instance() + std::vector < std::string > diagmodes_list = Profile::instance() ->ReadStringContainer("MAIN", "SupportedDiagModes", &isread); EXPECT_TRUE(isread); @@ -766,11 +758,11 @@ TEST_F(ProfileTest, CheckIntContainerInSecurityData) { Profile::instance()->config_file_name()); std::vector<int> force_unprotected_list = - profile::Profile::instance()->ReadIntContainer( + Profile::instance()->ReadIntContainer( "Security Manager", "ForceUnprotectedService", NULL); std::vector<int> force_protected_list = - profile::Profile::instance()->ReadIntContainer( + Profile::instance()->ReadIntContainer( "Security Manager", "ForceProtectedService", NULL); std::vector<int>::iterator res_unprotect = std::find(force_unprotected_list.begin(), force_unprotected_list.end(), 0x07); |