Back to index

unity  6.0.0
test_hud_button.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright 2012 Canonical Ltd.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License version 3, as
00006  * published by the  Free Software Foundation.
00007  *
00008  * This program is distributed in the hope that it will be useful, but
00009  * WITHOUT ANY WARRANTY; without even the implied warranties of
00010  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00011  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00012  * License for more details.
00013  *
00014  * You should have received a copy of both the GNU Lesser General Public
00015  * License version 3 along with this program.  If not, see
00016  * <http://www.gnu.org/licenses/>
00017  *
00018  * Authored by: Andrea Azzarone <azzaronea@gmail.com>
00019  *
00020  */
00021 
00022 #include <gtest/gtest.h>
00023 
00024 #include <Nux/Nux.h>
00025 #include <Nux/Layout.h>
00026 #include <UnityCore/Hud.h>
00027 
00028 #include "hud/HudButton.h"
00029 #include "unity-shared/DashStyle.h"
00030 #include "unity-shared/StaticCairoText.h"
00031 #include "unity-shared/UnitySettings.h"
00032 
00033 using namespace unity;
00034 
00035 namespace
00036 {
00037 
00038 TEST(TestHudButton, TestLabelOpacity)
00039 {
00040   Settings unity_settings;
00041   dash::Style dash_style;
00042   nux::ObjectPtr<hud::HudButton> button(new hud::HudButton());
00043   nux::Layout* layout = button->GetLayout();
00044 
00045   ASSERT_NE(layout, nullptr);
00046   ASSERT_EQ(layout->GetChildren().size(), 0);
00047 
00048   hud::Query::Ptr query(new hud::Query("<b>Op</b> Fi<b>le</b>", "","", "", "", NULL));
00049   button->SetQuery(query);
00050 
00051   auto children(layout->GetChildren());
00052   ASSERT_EQ(children.size(), 3);
00053 
00054   auto it = children.begin();
00055   nux::StaticCairoText* label = dynamic_cast<nux::StaticCairoText*>(*it);
00056   ASSERT_NE(label, nullptr);
00057   EXPECT_EQ(label->GetText(), "Op");
00058   EXPECT_EQ(label->GetTextColor().alpha, 1.0f);
00059 
00060   it++;
00061   label = dynamic_cast<nux::StaticCairoText*>(*it);
00062   ASSERT_NE(label, nullptr);
00063   EXPECT_EQ(label->GetText(), " Fi");
00064   EXPECT_EQ(label->GetTextColor().alpha, 0.5f);
00065 
00066   it++;
00067   label = dynamic_cast<nux::StaticCairoText*>(*it);
00068   ASSERT_NE(label, nullptr);
00069   EXPECT_EQ(label->GetText(), "le");
00070   EXPECT_EQ(label->GetTextColor().alpha, 1.0f);
00071 }
00072 
00073 }