Ticket #4849: test-barchivable.cpp

File test-barchivable.cpp, 1.0 KB (added by matjako, 10 years ago)

Test case for BSlider BArchivable implementation

Line 
1#include <Application.h>
2#include <InterfaceKit.h>
3
4/*
5    Tests BArchivable implementation for different BViews.
6*/
7class TestApp: public BApplication
8{
9    public:
10    TestApp(): BApplication("application/x-vnd.mk-testapp")
11    {
12        BWindow *window = new BWindow(BRect(20,20,330,220),"BArchivable Test",  B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_QUIT_ON_WINDOW_CLOSE);
13        window->Show();
14       
15        BView *view = new BView(window->Bounds(),"Container",0,B_FOLLOW_ALL);
16        window->AddChild(view);
17       
18
19        BMessage archive2;
20        BButton *button = new BButton(BRect(20,10,120,30),"Button", "Label", NULL, 0,100);
21        button->Archive(&archive2, true);
22        view->AddChild(dynamic_cast<BView*>(instantiate_object(&archive2)));   
23
24        BMessage archive;
25        BSlider *slider = new BSlider(BRect(20,40,120,70),"Slider", "Label", NULL, 0,100);
26        slider->Archive(&archive, true);
27        // compare this...
28        view->AddChild(dynamic_cast<BView*>(instantiate_object(&archive))); 
29        // to this ...
30        //view->AddChild(slider);   
31    }   
32};
33
34int main() 
35{
36    new TestApp();
37    be_app->Run();
38    return 0;
39}