fixup! TC utc_blink_ewk_view_app_name_user_agent_set_func refactoring.
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / unittest / utc_blink_ewk_view_resume_func.cpp
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.
4
5 #include "utc_blink_ewk_base.h"
6
7 class utc_blink_ewk_view_resume : public utc_blink_ewk_base
8 {
9 protected:
10   enum RunPhase {
11     PageLoadStart,
12     PageSuspended,
13     PageResumed
14   };
15
16 protected:
17   utc_blink_ewk_view_resume()
18     : phase(PageLoadStart)
19   {
20   }
21
22   /* Callback for quitting main loop */
23   void LoadProgress(Evas_Object* webview, double pr)
24   {
25     // Page started to load, after that we want to suspend right after
26     if (phase == PageLoadStart) {
27       phase = PageSuspended;
28       EventLoopStop(Success);
29     }
30   }
31
32   bool TimeOut()
33   {
34     if (phase == PageSuspended) {
35       phase = PageResumed;
36       EventLoopStop(Success);
37       return true;
38     }
39
40     return false;
41   }
42
43   void LoadFinished(Evas_Object* webview)
44   {
45     if (phase == PageResumed) {
46       EventLoopStop(Success);
47     } else {
48       EventLoopStop(Failure);
49     }
50   }
51
52 protected:
53   RunPhase phase;
54 };
55
56 /**
57  * @brief Positive test case of ewk_view_resume()
58  */
59 TEST_F(utc_blink_ewk_view_resume, POS_TEST)
60 {
61   if (!ewk_view_url_set(GetEwkWebView(), "http://www.google.pl"))
62     FAIL();
63
64   if (Success != EventLoopStart())
65     FAIL();
66
67   utc_message("Suspend");
68   ewk_view_suspend(GetEwkWebView());
69
70   if (Success != EventLoopStart(5.0)) // Wait few seconds to see if it realy was suspended
71     FAIL();
72
73   utc_message("Resume");
74   ewk_view_resume(GetEwkWebView());
75
76   if (Success != EventLoopStart())
77     FAIL();
78
79   evas_object_show(GetEwkWebView());
80   evas_object_show(GetEwkWindow());
81 }
82
83 /**
84  * @brief Negative test case of ewk_view_resume()
85  */
86 TEST_F(utc_blink_ewk_view_resume, NEG_TEST)
87 {
88   // This test is pointless. ewk_view_resume has no return value so we have nothing to test here.
89   ewk_view_resume(NULL);
90   evas_object_show(GetEwkWebView());
91   evas_object_show(GetEwkWindow());
92 }