1 // Copyright 2014 Samsung Electronics. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "utc_blink_ewk_context_form_autofill_profile_utils.h"
6 #include "utc_blink_ewk_base.h"
7 #include "ewk_autofill_profile.h"
12 Ewk_Autofill_Profile* getTestEwkAutofillProfile() {
13 Ewk_Autofill_Profile* profile = ewk_autofill_profile_new();
16 std::stringstream stream;
17 stream << TEST_AUTOFILL_PROFILE_ID;
18 std::string id = stream.str();
19 ewk_autofill_profile_data_set(profile, EWK_PROFILE_ID, id.c_str());
20 ewk_autofill_profile_data_set(profile, EWK_PROFILE_NAME, TEST_AUTOFILL_PROFILE_NAME);
21 ewk_autofill_profile_data_set(profile, EWK_PROFILE_COMPANY, TEST_AUTOFILL_PROFILE_COMPANY);
22 ewk_autofill_profile_data_set(profile, EWK_PROFILE_ADDRESS1, TEST_AUTOFILL_PROFILE_ADDRESS1);
23 ewk_autofill_profile_data_set(profile, EWK_PROFILE_ADDRESS2, TEST_AUTOFILL_PROFILE_ADDRESS2);
24 ewk_autofill_profile_data_set(profile, EWK_PROFILE_CITY_TOWN, TEST_AUTOFILL_PROFILE_CITY_TOWN);
25 ewk_autofill_profile_data_set(profile, EWK_PROFILE_STATE_PROVINCE_REGION, TEST_AUTOFILL_PROFILE_STATE_PROVINCE_REGION);
26 ewk_autofill_profile_data_set(profile, EWK_PROFILE_ZIPCODE, TEST_AUTOFILL_PROFILE_ZIPCODE);
27 ewk_autofill_profile_data_set(profile, EWK_PROFILE_COUNTRY, TEST_AUTOFILL_PROFILE_COUNTRY);
28 ewk_autofill_profile_data_set(profile, EWK_PROFILE_PHONE, TEST_AUTOFILL_PROFILE_PHONE);
29 ewk_autofill_profile_data_set(profile, EWK_PROFILE_EMAIL, TEST_AUTOFILL_PROFILE_EMAIL);
34 bool checkOne(Ewk_Autofill_Profile* profileToCheck, const char* reference,
35 Ewk_Autofill_Profile_Data_Type kind, const char* errMessage) {
36 const char* ptr = ewk_autofill_profile_data_get(profileToCheck, kind);
38 utc_message("%s, expected: %s obtained: NULL\n", errMessage, reference);
41 utc_message("%s, expected: %s obtained: %s\n", errMessage, reference, ptr);
43 return (0 == strcmp(reference, ptr));
46 bool checkIfProfileContainsTestData(Ewk_Autofill_Profile* profileToCheck) {
47 if (NULL == profileToCheck) {
50 bool dataValid = true;
51 if (TEST_AUTOFILL_PROFILE_ID != ewk_autofill_profile_id_get(profileToCheck)) {
52 utc_message("profile ID check failed %i %i", TEST_AUTOFILL_PROFILE_ID, ewk_autofill_profile_id_get(profileToCheck));
55 dataValid = checkOne(profileToCheck, TEST_AUTOFILL_PROFILE_NAME, EWK_PROFILE_NAME, "name") && dataValid;
56 dataValid = checkOne(profileToCheck, TEST_AUTOFILL_PROFILE_COMPANY, EWK_PROFILE_COMPANY, "company") && dataValid;
57 dataValid = checkOne(profileToCheck, TEST_AUTOFILL_PROFILE_ADDRESS1, EWK_PROFILE_ADDRESS1, "address1") && dataValid;
58 dataValid = checkOne(profileToCheck, TEST_AUTOFILL_PROFILE_ADDRESS2, EWK_PROFILE_ADDRESS2, "address2") && dataValid;
59 dataValid = checkOne(profileToCheck, TEST_AUTOFILL_PROFILE_CITY_TOWN, EWK_PROFILE_CITY_TOWN, "city") && dataValid;
60 dataValid = checkOne(profileToCheck, TEST_AUTOFILL_PROFILE_STATE_PROVINCE_REGION, EWK_PROFILE_STATE_PROVINCE_REGION, "province") && dataValid;
61 dataValid = checkOne(profileToCheck, TEST_AUTOFILL_PROFILE_ZIPCODE, EWK_PROFILE_ZIPCODE, "zipcode") && dataValid;
62 dataValid = checkOne(profileToCheck, TEST_AUTOFILL_PROFILE_COUNTRY, EWK_PROFILE_COUNTRY, "country") && dataValid;
63 dataValid = checkOne(profileToCheck, TEST_AUTOFILL_PROFILE_PHONE, EWK_PROFILE_PHONE, "phone") && dataValid;
64 dataValid = checkOne(profileToCheck, TEST_AUTOFILL_PROFILE_EMAIL, EWK_PROFILE_EMAIL, "email") && dataValid;
68 void utc_blink_ewk_context_form_autofill_profile_base::PostSetUp() {
73 void utc_blink_ewk_context_form_autofill_profile_base::PreTearDown() {