/*
* Copyright (C) 2019 ~ 2020 Deepin Technology Co., Ltd.
*
* Author:     zhangyunfeng <zhangyunfeng@uniontech.com>
* Maintainer: zhangyunfeng <zhangyunfeng@uniontech.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "ut_worker.h"

ut_worker_test::ut_worker_test()
{

}

void ut_worker_test::SetUp()
{
    m_worker = Worker::Instance();
}

void ut_worker_test::TearDown()
{
    // Worker 是单例，不需要手动 delete
    m_worker = nullptr;
}

/*******************************************************************************
 1. @函数:    setDesktopMode
 2. @说明:    测试设置桌面样式
*******************************************************************************/
TEST_F(ut_worker_test, setDesktopMode)
{
    ASSERT_TRUE(m_worker->m_model != nullptr);
    // 测试时尚模式
    m_worker->setDesktopMode(Model::DesktopMode::FashionMode);

    // 测试高效模式
    m_worker->setDesktopMode(Model::DesktopMode::EfficientMode);
}

/*******************************************************************************
 1. @函数:    setWMMode
 2. @说明:    测试设置运行模式
*******************************************************************************/
TEST_F(ut_worker_test, setWMMode)
{
    m_worker->setWMMode(Model::WM_3D);
    m_worker->setWMMode(Model::WM_2D);
}

/*******************************************************************************
 1. @函数:    setIcon
 2. @说明:    测试设置图标
*******************************************************************************/
TEST_F(ut_worker_test, setIcon)
{
    IconStruct tmp;
    tmp.Id = "1";
    tmp.Path = "333";
    tmp.Deletable = false;
    tmp.Pixmap = "pix";
    m_worker->setIcon(tmp);
}

/*******************************************************************************
 1. @函数:    onDisplayModeChanged
 2. @说明:    测试桌面样式改变响应函数
*******************************************************************************/
TEST_F(ut_worker_test, onDisplayModeChanged)
{
    m_worker->onDisplayModeChanged(Model::DesktopMode::EfficientMode);
    EXPECT_EQ(Model::DesktopMode::EfficientMode, m_worker->m_model->m_desktopMode);
    m_worker->onDisplayModeChanged(Model::DesktopMode::FashionMode);
    EXPECT_EQ(Model::DesktopMode::FashionMode, m_worker->m_model->m_desktopMode);
}

/*******************************************************************************
 1. @函数:    onIconRefreshed
 2. @说明:    测试图标刷新响应函数
*******************************************************************************/
TEST_F(ut_worker_test, onIconRefreshed)
{
    m_worker->onIconRefreshed("icon");
}

/*******************************************************************************
 1. @函数:    onIconListChanged
 2. @说明:    测试图标列表变化响应函数
*******************************************************************************/
TEST_F(ut_worker_test, onIconListChanged)
{
    QString value = "[{\"Id\":\"bloom-dark\",\"Path\":\"/usr/share/icons/bloom-dark\",\"Deletable\":false}]";
    IconStruct tmp;
    tmp.Id = "1";
    tmp.Path = "333";
    tmp.Deletable = false;
    tmp.Pixmap = "pix";
    m_worker->m_model->m_iconList.append(tmp);
    m_worker->onIconListChanged(value);
}
