Property refactor in dali-core: Toolkit changes for compiling
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-ItemLayout.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <iostream>
19 #include <stdlib.h>
20
21 // Need to override adaptor classes for toolkit test harness, so include
22 // test harness headers before dali headers.
23 #include <dali-toolkit-test-suite-utils.h>
24
25 #include <dali.h>
26 #include <dali-toolkit/dali-toolkit.h>
27
28 using namespace Dali;
29 using namespace Toolkit;
30
31 namespace
32 {
33 const unsigned int TOTAL_ITEM_NUMBER = 200;
34 const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
35
36
37 // Implementation of ItemFactory for providing actors to ItemView
38 class TestItemFactory : public ItemFactory
39 {
40 public:
41
42   /**
43    * Constructor
44    * @param application class, stored as reference
45    */
46   TestItemFactory()
47   {
48   }
49
50 public: // From ItemFactory
51
52   /**
53    * Query the number of items available from the factory.
54    * The maximum available item has an ID of GetNumberOfItems() - 1.
55    */
56   virtual unsigned int GetNumberOfItems()
57   {
58     return TOTAL_ITEM_NUMBER;
59   }
60
61   /**
62    * Create an Actor to represent a visible item.
63    * @param itemId
64    * @return the created actor.
65    */
66   virtual Actor NewItem(unsigned int itemId)
67   {
68     // Create an image actor for this item
69     Image image = ResourceImage::New( TEST_IMAGE_FILE_NAME );
70     Actor actor = ImageActor::New(image);
71
72     return actor;
73   }
74 };
75 } // namespace
76
77 int UtcDaliItemLayoutSetAndGetOrientation(void)
78 {
79   ToolkitTestApplication application;
80
81   // Create the ItemView actor
82   TestItemFactory factory;
83   ItemView view = ItemView::New(factory);
84
85   // Create a grid layout and add it to ItemView
86   GridLayoutPtr gridLayout = GridLayout::New();
87   view.AddLayout(*gridLayout);
88
89   // Set the orientation of the layout to be horizontal from left to right
90   ItemLayoutPtr layout = view.GetLayout(0);
91   layout->SetOrientation(ControlOrientation::Left);
92
93   // Check the orientation of the layout is horizontal from left to right
94   DALI_TEST_CHECK(layout->GetOrientation() == ControlOrientation::Left);
95   END_TEST;
96 }