Back to index

nux  3.0.0
gtest-nux-view.cpp
Go to the documentation of this file.
00001 #include <string>
00002 #include <fstream>
00003 
00004 #include <iostream>
00005 #include <gmock/gmock.h>
00006 #include <boost/filesystem.hpp>
00007 #include <glib.h>
00008 
00009 #include "Nux/Nux.h"
00010 #include "Nux/HLayout.h"
00011 #include "Nux/StaticText.h"
00012 #include "Nux/ProgramFramework/TestView.h"
00013 
00014 
00015 using namespace testing;
00016 
00017 namespace {
00018 
00019 TEST(TestView, TestViewEnable)
00020 {
00021   nux::NuxInitialize(0);
00022   nux::WindowThread *wnd_thread = nux::CreateNuxWindow("View Test", 300, 200,
00023     nux::WINDOWSTYLE_NORMAL, NULL, false, NULL, NULL);
00024 
00025   nux::TestView* test_view = new nux::TestView("");
00026   
00027   test_view->EnableView();
00028   EXPECT_TRUE(test_view->IsViewEnabled());
00029 
00030   test_view->DisableView();
00031   EXPECT_FALSE(test_view->IsViewEnabled());
00032 
00033 
00034   test_view->UnReference();
00035   delete wnd_thread;
00036 }
00037 
00038 TEST(TestView, TestQueueDraw)
00039 {
00040   nux::NuxInitialize(0);
00041   nux::WindowThread *wnd_thread = nux::CreateNuxWindow("View Test", 300, 200,
00042     nux::WINDOWSTYLE_NORMAL, NULL, false, NULL, NULL);
00043 
00044   nux::TestView* main_view = new nux::TestView("");
00045 
00046   nux::HLayout* hlayout = new nux::HLayout("");
00047   main_view->SetLayout(hlayout);
00048 
00049   nux::TestView* test_view1 = new nux::TestView("");
00050   hlayout->AddView(test_view1);
00051   nux::TestView* test_view2 = new nux::TestView("");
00052   hlayout->AddView(test_view2);
00053   nux::TestView* test_view3 = new nux::TestView("");
00054   hlayout->AddView(test_view3);
00055 
00056   hlayout->ComputeContentSize();
00057   EXPECT_EQ(main_view->calls_to_queue_draw_, 0);
00058   EXPECT_EQ(test_view1->calls_to_queue_draw_, 0);
00059   EXPECT_EQ(test_view2->calls_to_queue_draw_, 0);
00060   EXPECT_EQ(test_view3->calls_to_queue_draw_, 0);
00061 
00062   main_view->QueueDraw();
00063   EXPECT_EQ(main_view->calls_to_queue_draw_, 1);
00064   EXPECT_EQ(test_view1->calls_to_queue_draw_, 1);
00065   EXPECT_EQ(test_view2->calls_to_queue_draw_, 1);
00066   EXPECT_EQ(test_view3->calls_to_queue_draw_, 1);
00067 
00068   int old_size = wnd_thread->GetDrawList().size();
00069   main_view->QueueDraw();
00070   test_view2->QueueDraw();
00071   int new_size = wnd_thread->GetDrawList().size();
00072   EXPECT_EQ(old_size, new_size);  // LP: #1014610
00073 
00074   EXPECT_EQ(main_view->calls_to_queue_draw_, 2);
00075   EXPECT_EQ(test_view1->calls_to_queue_draw_, 1);
00076   EXPECT_EQ(test_view2->calls_to_queue_draw_, 2);
00077   EXPECT_EQ(test_view3->calls_to_queue_draw_, 1);
00078 
00079   main_view->UnReference();
00080   delete wnd_thread;
00081 }
00082 
00083 }