summaryrefslogtreecommitdiff
path: root/unittest/ui_app_ambient_unittest.cpp
blob: 80c5904b77af7100c91431ee6e57f35ac37a524b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
 * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <unistd.h>
#include <stdio.h>

#include "aul_fake.h"
#include "alarm_fake.h"
#include "ui_app_ambient.h"

class UIAppAmbientTest : public ::testing::Test {
  protected:
    void SetUp() override {

    }
    void TearDown() override {

    }

};

static int __aul_app_get_appid_bypid_fake(int pid, char* appidid, int size)
{
  return 0;
}

static int __aul_app_com_create_fake(
  const char *endpoint,
  aul_app_com_permission_h permission,
  app_com_cb callback,
  void *user_data,
  aul_app_com_connection_h *connection)
{
  return 0;
}

static int __aul_app_com_send_fake(const char *endpoint, bundle *envelope)
{
  return 0;
}

static alarm_entry_t* __alarmmgr_create_alarm_fake(void)
{
  alarm_entry_t *base_info = (alarm_entry_t *)malloc(sizeof(alarm_entry_t));
  return base_info;
}

static int __alarmmgr_free_alarm_fake(alarm_entry_t *alarm)
{
  free(alarm);
  return 0;
}

static int __alarmmgr_init_fake(const char *appid)
{
  return 0;
}

static int __alarmmgr_set_time_fake(alarm_entry_t *info, alarm_date_t date)
{
  return 0;
}

static int __alarmmgr_set_repeat_mode_fake(alarm_entry_t *info, alarm_repeat_mode_t mode, int value)
{
  return 0;
}

static int __alarmmgr_add_alarm_with_localtime_fake(alarm_entry_t *info, const char *dest, int *alarm_id)
{
  return 0;
}

static void __frame_cb(void *user_data)
{
}

static void __changed_cb(bool mode, bundle *data, void *user_data)
{
  printf("mode : %d", mode);
}

TEST_F(UIAppAmbientTest, ui_app_ambient_set_lifecycle_p)
{
  int ret;
  ui_app_ambient_lifecycle_callback_s callback;
  callback.frame_updated = __frame_cb;
  callback.ambient_changed = __changed_cb;

  aul_app_get_appid_bypid_fake.custom_fake = __aul_app_get_appid_bypid_fake;
  aul_app_com_create_fake.custom_fake = __aul_app_com_create_fake;
  alarmmgr_create_alarm_fake.custom_fake = __alarmmgr_create_alarm_fake;
  alarmmgr_free_alarm_fake.custom_fake = __alarmmgr_free_alarm_fake;
  alarmmgr_init_fake.custom_fake = __alarmmgr_init_fake;
  alarmmgr_set_time_fake.custom_fake = __alarmmgr_set_time_fake;
  alarmmgr_set_repeat_mode_fake.custom_fake = __alarmmgr_set_repeat_mode_fake;
  alarmmgr_add_alarm_with_localtime_fake.custom_fake = __alarmmgr_add_alarm_with_localtime_fake;

  ret = ui_app_ambient_set_lifecycle(&callback, NULL);
  EXPECT_EQ(0, ret);

  ui_app_ambient_unset_lifecycle();
}

TEST_F(UIAppAmbientTest, ui_app_ambient_set_update_period_p)
{
  int ret;
  ret = ui_app_ambient_set_update_period(UI_APP_AMBIENT_UPDATE_MINUTE);
  EXPECT_EQ(0, ret);
}

TEST_F(UIAppAmbientTest, ui_app_ambient_get_update_period_p)
{
  int ret;
  ui_app_ambient_update_period_e period;

  ret = ui_app_ambient_get_update_period(&period);
  EXPECT_EQ(0, ret);
}

TEST_F(UIAppAmbientTest, ui_app_ambient_get_update_period_n)
{
  int ret;

  ret = ui_app_ambient_get_update_period(NULL);
  EXPECT_NE(0, ret);
}

TEST_F(UIAppAmbientTest, ui_app_ambient_notify_p)
{
  int ret;
  aul_app_com_send_fake.custom_fake = __aul_app_com_send_fake;

  ret = ui_app_ambient_notify_event(UI_APP_AMBIENT_EVENT_READY, NULL);
  EXPECT_EQ(0, ret);
}