Back to index

nux  3.0.0
gtest-nux-windowcompositor.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/ProgramFramework/TestView.h"
00012 
00013 using namespace testing;
00014 
00015 namespace {
00016 
00017 TEST(TestWindowCompositor, TestSetKeyFocusArea)
00018 {
00019   nux::NuxInitialize(0);
00020   nux::WindowThread *wnd_thread = nux::CreateNuxWindow("Nux Window", 300, 200,
00021     nux::WINDOWSTYLE_NORMAL, NULL, false, NULL, NULL);
00022 
00023   nux::TestView* test_view0 = new nux::TestView();
00024   nux::TestView* test_view1 = new nux::TestView();
00025 
00026   nux::HLayout* layout = new nux::HLayout();
00027   
00028   layout->AddView(test_view0, 1);
00029   layout->AddView(test_view1, 1);
00030 
00031   wnd_thread->SetLayout(layout);
00032 
00033   // Set keyboard focus on test_view0
00034   {
00035     wnd_thread->GetWindowCompositor().SetKeyFocusArea(test_view0);
00036 
00037     // Check that test_view0 has registered a keynav focus event
00038     EXPECT_EQ(test_view0->registered_begin_keynav_focus_, true);
00039     EXPECT_EQ(test_view0->registered_end_keynav_focus_, false);
00040 
00041     EXPECT_EQ(test_view1->registered_begin_keynav_focus_, false);
00042     EXPECT_EQ(test_view1->registered_end_keynav_focus_, false);
00043 
00044     test_view0->ResetKeyFocusEvents();
00045   }
00046 
00047   // Set keyboard focus on test_view1
00048   {
00049     wnd_thread->GetWindowCompositor().SetKeyFocusArea(test_view1);
00050 
00051     EXPECT_EQ(test_view0->registered_begin_keynav_focus_, false);
00052     // Check that test_view0 has loast the keynav focus.
00053     EXPECT_EQ(test_view0->registered_end_keynav_focus_, true);
00054 
00055     // Check that test_view1 has registered a keynav focus event
00056     EXPECT_EQ(test_view1->registered_begin_keynav_focus_, true);
00057     EXPECT_EQ(test_view1->registered_end_keynav_focus_, false);
00058   }
00059 
00060   delete wnd_thread;
00061 }
00062 
00063 
00064 }