From a2e24cf5ce7f5154f85ea9fb75d52356f5a2e492 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Sat, 11 Jun 2005 13:21:25 +0000 Subject: [PATCH] Added a test which our app_server/libbe does not pass yet. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13058 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/tests/kits/interface/Jamfile | 5 ++ src/tests/kits/interface/PulseTest.cpp | 69 ++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 src/tests/kits/interface/PulseTest.cpp diff --git a/src/tests/kits/interface/Jamfile b/src/tests/kits/interface/Jamfile index c87c3d9c62..a7205d1829 100644 --- a/src/tests/kits/interface/Jamfile +++ b/src/tests/kits/interface/Jamfile @@ -96,6 +96,11 @@ SimpleTest GetMouseTest : : be ; +SimpleTest PulseTest : + PulseTest.cpp + : be + ; + SEARCH on [ FGristFiles ScrollView.cpp CheckBox.cpp ChannelSlider.cpp ChannelControl.cpp ] = [ FDirName $(OBOS_TOP) src kits interface ] ; diff --git a/src/tests/kits/interface/PulseTest.cpp b/src/tests/kits/interface/PulseTest.cpp new file mode 100644 index 0000000000..f2d6970606 --- /dev/null +++ b/src/tests/kits/interface/PulseTest.cpp @@ -0,0 +1,69 @@ +#include +#include +#include + +#include +#include + +static void +ChangeColor(rgb_color &color) +{ + color.red = rand() % 255; + color.green = rand() % 255; +} + + +class PulseView : public BView { +public: + PulseView(BRect rect, const char *name, uint32 resizeMode, uint32 flags) + : BView(rect, name, resizeMode, flags) + { + fLeft = Bounds().OffsetToCopy(B_ORIGIN); + fLeft.right -= Bounds().Width() / 2; + fRight = fLeft.OffsetByCopy(fLeft.Width(), 0); + fColor.red = 255; + fColor.green = 255; + fColor.blue = 255; + } + + virtual void Pulse() + { + SetHighColor(fColor); + BRect rect = fRight; + + if (fLeftTurn) + rect = fLeft; + + FillRect(rect, B_SOLID_HIGH); + + fLeftTurn = !fLeftTurn; + + ChangeColor(fColor); + } + + BRect fLeft; + BRect fRight; + + bool fLeftTurn; + rgb_color fColor; +}; + +void +show_window(BWindow *window) +{ + BView *view = new PulseView(window->Bounds(), "pulse view", B_FOLLOW_ALL, B_PULSE_NEEDED|B_WILL_DRAW); + window->SetPulseRate(500000); + window->AddChild(view); + window->Show(); +} + + +int main() +{ + srand(time(NULL)); + BApplication app("application/x-vnd.pulse_test"); + BWindow *window = new BWindow(BRect(100, 100, 400, 300), "pulse test", + B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE | B_ASYNCHRONOUS_CONTROLS | B_NOT_RESIZABLE); + show_window(window); + app.Run(); +}