b41c2495bddc7c580aa6bb45d8e59e4dca9902be
[platform/core/appfw/appcore-widget.git] / test / unit_tests / test_widget_app_cpp.cc
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include <gmock/gmock.h>
18 #include <widget_app.hpp>
19
20 namespace {
21
22 class WidgetApp : public tizen_appfw::WidgetAppBase {
23  public:
24   class Instance : public InstanceBase {
25    public:
26     class Factory : public InstanceBase::Factory {
27      public:
28       std::unique_ptr<InstanceBase> Create(widget_context_h h) override {
29         return std::unique_ptr<InstanceBase>(new Instance(h));
30       }
31     };
32
33     Instance(widget_context_h h) : InstanceBase(h) {}
34     void OnCreate(const tizen_base::Bundle& content, int w, int h) override {}
35     void OnDestroy(DestroyType reason, tizen_base::Bundle* content) override {}
36     void OnPause() override {}
37     void OnResume() override {}
38     void OnResize(int w, int h) override {}
39     void OnUpdate(const tizen_base::Bundle& content, bool force) override {}
40   };
41
42   WidgetApp() {}
43   void OnCreate() override {}
44   void OnTerminate() override {}
45 };
46
47 }  // namespace
48
49 TEST(WidgetAppCppTest, Run_InvalidParameter) {
50   WidgetApp app;
51   std::unique_ptr<tizen_appfw::WidgetAppBase::InstanceBase::Factory> factory(
52       new WidgetApp::Instance::Factory());
53
54   int ret = app.Run(0, nullptr, std::move(factory));
55   EXPECT_EQ(ret, APP_ERROR_INVALID_PARAMETER);
56 }