Cleanup code
[platform/framework/web/nwrt.git] / tests / popup / test_popup.cc
1 // Copyright 2015 Samsung Electronics Co, Ltd. 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.
4
5 #include <Elementary.h>
6 #include <string>
7 #include <iostream>
8 #include "popup/popup.h"
9 #include "popup/popup_string.h"
10
11 int main(int argc, char **argv) {
12   const char* kLocaleKorean = "ko_KR";
13   setlocale(LC_ALL, kLocaleKorean);
14   bindtextdomain("wrt", "/usr/share/locale");
15
16   Evas_Object* win;
17
18   elm_init(argc, argv);
19   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
20
21   win = elm_win_util_standard_add("sample", "Sample");
22   elm_win_autodel_set(win, EINA_TRUE);
23
24   const std::string title = wrt::popup_string::kPopupTitleCert;
25   const std::string body_text =
26     wrt::popup_string::GetText(wrt::popup_string::kPopupBodyCert) +
27     "<br>" + "http://url.url";
28   const std::string check_label =
29     wrt::popup_string::kPopupCheckRememberPreference;
30   const std::string entry_1_label = wrt::popup_string::kPopupLabelAuthusername;
31   const std::string entry_2_label = wrt::popup_string::kPopupLabelPassword;
32
33   wrt::Popup* popup = wrt::Popup::CreatePopup(win);
34   popup->SetTitle(title);
35   popup->SetBody(body_text);
36   popup->SetFirstEntry(entry_1_label, wrt::Popup::EntryType::Edit);
37   popup->SetSecondEntry(entry_2_label, wrt::Popup::EntryType::PwEdit);
38   popup->SetCheckBox(check_label);
39   popup->SetButtonType(wrt::Popup::ButtonType::AllowDenyButton);
40   popup-> SetResultHandler([](wrt::Popup* popup, void* user_data) {
41     std::cout<< popup->GetFirstEntryResult() << std::endl;
42     std::cout<< popup->GetSecondEntryResult() << std::endl;
43     std::cout<< popup->GetCheckBoxResult() << std::endl;
44     std::cout<< popup->GetButtonResult() << std::endl;
45   }, NULL);
46   popup->Show();
47
48   elm_language_set(kLocaleKorean);
49
50   evas_object_resize(win, 200, 100);
51   evas_object_show(win);
52
53   elm_run();
54   elm_shutdown();
55
56   return 0;
57 }