~s-cecilio/lomse/master

« back to all changes in this revision

Viewing changes to src/tests/lomse_test_sizers.cpp

  • Committer: cecilios
  • Date: 2010-11-14 17:47:31 UTC
  • Revision ID: git-v1:1fa3764c8c4d338b95b1a537b1e78271170c0025
latest new code. demo_1 tested on linux and win32

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//--------------------------------------------------------------------------------------
 
2
//  This file is part of the Lomse library.
 
3
//  Copyright (c) 2010 Lomse project
 
4
//
 
5
//  Lomse is free software; you can redistribute it and/or modify it under the
 
6
//  terms of the GNU General Public License as published by the Free Software Foundation,
 
7
//  either version 3 of the License, or (at your option) any later version.
 
8
//
 
9
//  Lomse is distributed in the hope that it will be useful, but WITHOUT ANY
 
10
//  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 
11
//  PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 
12
//
 
13
//  You should have received a copy of the GNU General Public License along
 
14
//  with Lomse; if not, see <http://www.gnu.org/licenses/>.
 
15
//
 
16
//  For any comment, suggestion or feature request, please contact the manager of
 
17
//  the project at cecilios@users.sourceforge.net
 
18
//
 
19
//-------------------------------------------------------------------------------------
 
20
 
 
21
#include <UnitTest++.h>
 
22
#include <sstream>
 
23
#include "lomse_config.h"
 
24
 
 
25
//classes related to these tests
 
26
#include "lomse_injectors.h"
 
27
#include "lomse_sizers.h"
 
28
#include "lomse_gm_basic.h"
 
29
 
 
30
using namespace UnitTest;
 
31
using namespace std;
 
32
using namespace lomse;
 
33
 
 
34
 
 
35
class SizersTestFixture
 
36
{
 
37
public:
 
38
 
 
39
    SizersTestFixture()     //SetUp fixture
 
40
    {
 
41
        m_pLibraryScope = new LibraryScope(cout);
 
42
        m_scores_path = LOMSE_TEST_SCORES_PATH;
 
43
    }
 
44
 
 
45
    ~SizersTestFixture()    //TearDown fixture
 
46
    {
 
47
        delete m_pLibraryScope;
 
48
    }
 
49
 
 
50
    LibraryScope* m_pLibraryScope;
 
51
    std::string m_scores_path;
 
52
};
 
53
 
 
54
SUITE(SizersTest)
 
55
{
 
56
 
 
57
    // FlowSizer vertical -------------------------------------------------
 
58
 
 
59
    TEST_FIXTURE(SizersTestFixture, SizersTest_FlowVerticalTakesAllWidth)
 
60
    {
 
61
        FlowSizer sizer(FlowSizer::k_vertical);
 
62
        GmoStubScore stub(NULL);
 
63
        GmoBoxScorePage box(&stub, NULL);
 
64
        sizer.add_child( new SizerChild(&box) );
 
65
        sizer.layout(2100.0f, 2970.0f);
 
66
        CHECK( sizer.is_vertical() == true );
 
67
        CHECK( box.get_width() == 2100.0f );
 
68
        CHECK( box.get_height() == _LOMSE_CAN_GROW );
 
69
    }
 
70
 
 
71
    // FlowSizer horizontal -----------------------------------------------
 
72
 
 
73
    TEST_FIXTURE(SizersTestFixture, SizersTest_FlowHorizontalTakesAllHeight)
 
74
    {
 
75
        FlowSizer sizer(FlowSizer::k_horizontal);
 
76
        GmoStubScore stub(NULL);
 
77
        GmoBoxScorePage box(&stub, NULL);
 
78
        sizer.add_child( new SizerChild(&box) );
 
79
        sizer.layout(2100.0f, 2970.0f);
 
80
        CHECK( sizer.is_vertical() == false );
 
81
        CHECK( box.get_width() == _LOMSE_CAN_GROW );
 
82
        CHECK( box.get_height() == 2970.0f );
 
83
    }
 
84
 
 
85
}
 
86
 
 
87