2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 #include <shortcut_db.h>
17 #include <shortcut_private.h>
18 #include <gtest/gtest.h>
20 #include "system_info_mock.h"
22 #include "test_fixture.h"
24 class Mocks : public ::testing::NiceMock<SystemInfoMock>,
25 public ::testing::NiceMock<GioMock> {};
27 class ShortcutDbTest : public TestFixture {
29 ShortcutDbTest() : TestFixture(std::make_unique<Mocks>()) {}
30 virtual ~ShortcutDbTest() {}
31 virtual void SetUp() {}
32 virtual void TearDown() {}
35 TEST_F(ShortcutDbTest, Init) {
36 int r = shortcut_db_init();
37 EXPECT_EQ(SHORTCUT_ERROR_IO_ERROR, r);
39 GList* list = nullptr;
40 r = shortcut_db_get_list("not_working", &list);
41 EXPECT_EQ(SHORTCUT_ERROR_IO_ERROR, r);
43 r = shortcut_set_db_path("./db.db");
44 EXPECT_EQ(SHORTCUT_ERROR_NONE, r);
46 r = shortcut_db_init();
47 EXPECT_EQ(SHORTCUT_ERROR_NONE, r);
49 r = shortcut_db_get_list("working", &list);
50 EXPECT_EQ(SHORTCUT_ERROR_NONE, r);
51 EXPECT_EQ(nullptr, list);