[M120 Migration][MM] Support W3C EME
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / unittest / utc_blink_ewk_view_suspend_func.cpp
1 // Copyright 2014-2016 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.
4
5 #include "utc_blink_ewk_base.h"
6
7 class utc_blink_ewk_view_suspend : public utc_blink_ewk_base
8 {
9 protected:
10  utc_blink_ewk_view_suspend()
11      : after_progress(false), result_url_set(EINA_FALSE) {}
12
13  void LoadProgress(Evas_Object* webview, double progress) override {
14    if (!after_progress) {
15      // Page started to load, after that we want to suspend it
16      after_progress = true;
17      EventLoopStop(utc_blink_ewk_base::Success);
18    }
19   }
20
21   bool TimeOut() override {
22     // If we reached timeout then load,finished (and load,error) was not called
23     // we expect that - this indicates that suspend did work
24     EventLoopStop(utc_blink_ewk_base::Success);
25     return true;
26   }
27
28   void LoadFinished(Evas_Object* webview) override {
29     // Load finished should never be called after suspend
30     EventLoopStop(utc_blink_ewk_base::Failure);
31   }
32
33   static void job_url_set(utc_blink_ewk_base* data) {
34     utc_blink_ewk_view_suspend* owner =
35         static_cast<utc_blink_ewk_view_suspend*>(data);
36     owner->result_url_set =
37         ewk_view_url_set(owner->GetEwkWebView(), "http://www.google.pl");
38   }
39
40   bool after_progress;
41   Eina_Bool result_url_set;
42 };
43
44 /**
45  * @brief Positive test case of ewk_view_suspend()
46  */
47 TEST_F(utc_blink_ewk_view_suspend, POS_TEST)
48 {
49   SetTestJob(utc_blink_ewk_view_suspend::job_url_set);
50
51   utc_blink_ewk_base::MainLoopResult main_result = EventLoopStart();
52   if (main_result != utc_blink_ewk_base::Success)
53     FAIL();
54
55   ASSERT_EQ(EINA_TRUE, result_url_set);
56
57   ewk_view_suspend(GetEwkWebView());
58
59   main_result = EventLoopStart(5.0);
60   if (main_result != utc_blink_ewk_base::Success)
61     FAIL();
62
63   evas_object_show(GetEwkWebView());
64   evas_object_show(GetEwkWindow());
65 }
66
67 /**
68  * @brief Negative test case of ewk_view_suspend()
69  */
70 TEST_F(utc_blink_ewk_view_suspend, NEG_TEST)
71 {
72   ewk_view_suspend(NULL);
73   evas_object_show(GetEwkWebView());
74   evas_object_show(GetEwkWindow());
75 }