Added two tests:
* statusbar was used to test and improve some BStatusBar behavior * lagging_get_mouse demonstrates what the problem is with older applications using synchronous GetMouse() calls without specifying that they actually don't care about mouse history. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26327 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -173,6 +173,7 @@ SubInclude HAIKU_TOP src tests servers app drawing_modes ;
|
||||
SubInclude HAIKU_TOP src tests servers app event_mask ;
|
||||
SubInclude HAIKU_TOP src tests servers app following ;
|
||||
SubInclude HAIKU_TOP src tests servers app idle_test ;
|
||||
SubInclude HAIKU_TOP src tests servers app lagging_get_mouse ;
|
||||
SubInclude HAIKU_TOP src tests servers app lock_focus ;
|
||||
SubInclude HAIKU_TOP src tests servers app look_and_feel ;
|
||||
SubInclude HAIKU_TOP src tests servers app menu_crash ;
|
||||
@@ -183,6 +184,7 @@ SubInclude HAIKU_TOP src tests servers app regularapps ;
|
||||
SubInclude HAIKU_TOP src tests servers app resize_limits ;
|
||||
SubInclude HAIKU_TOP src tests servers app scrollbar ;
|
||||
SubInclude HAIKU_TOP src tests servers app scrolling ;
|
||||
SubInclude HAIKU_TOP src tests servers app statusbar ;
|
||||
SubInclude HAIKU_TOP src tests servers app stress_test ;
|
||||
SubInclude HAIKU_TOP src tests servers app textview ;
|
||||
SubInclude HAIKU_TOP src tests servers app view_state ;
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
SubDir HAIKU_TOP src tests servers app statusbar ;
|
||||
|
||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
AddSubDirSupportedPlatforms libbe_test ;
|
||||
|
||||
UseHeaders [ FDirName os app ] ;
|
||||
UseHeaders [ FDirName os interface ] ;
|
||||
|
||||
SimpleTest LaggingGetMouse :
|
||||
main.cpp
|
||||
: be ;
|
||||
|
||||
if ( $(TARGET_PLATFORM) = libbe_test ) {
|
||||
HaikuInstall install-test-apps : $(HAIKU_APP_TEST_DIR) : LaggingGetMouse
|
||||
: tests!apps ;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
// main.cpp
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <Application.h>
|
||||
#include <View.h>
|
||||
#include <Window.h>
|
||||
|
||||
class TestView : public BView {
|
||||
|
||||
public:
|
||||
TestView(BRect frame, const char* name,
|
||||
uint32 resizeFlags, uint32 flags);
|
||||
|
||||
virtual void Draw(BRect updateRect);
|
||||
virtual void MouseDown(BPoint where);
|
||||
|
||||
private:
|
||||
BList fMouseSamples;
|
||||
};
|
||||
|
||||
// constructor
|
||||
TestView::TestView(BRect frame, const char* name,
|
||||
uint32 resizeFlags, uint32 flags)
|
||||
: BView(frame, name, resizeFlags, flags),
|
||||
fMouseSamples(128)
|
||||
{
|
||||
}
|
||||
|
||||
// Draw
|
||||
void
|
||||
TestView::Draw(BRect updateRect)
|
||||
{
|
||||
int32 count = fMouseSamples.CountItems();
|
||||
if (count > 0) {
|
||||
BPoint* p = (BPoint*)fMouseSamples.ItemAtFast(0);
|
||||
MovePenTo(*p);
|
||||
}
|
||||
|
||||
for (int32 i = 0; i < count; i++) {
|
||||
BPoint* p = (BPoint*)fMouseSamples.ItemAtFast(i);
|
||||
StrokeLine(*p);
|
||||
}
|
||||
}
|
||||
|
||||
// MouseDown
|
||||
void
|
||||
TestView::MouseDown(BPoint where)
|
||||
{
|
||||
// clear previous stroke
|
||||
int32 count = fMouseSamples.CountItems();
|
||||
for (int32 i = 0; i < count; i++)
|
||||
delete (BPoint*)fMouseSamples.ItemAtFast(i);
|
||||
fMouseSamples.MakeEmpty();
|
||||
FillRect(Bounds(), B_SOLID_LOW);
|
||||
|
||||
// sample new stroke
|
||||
uint32 buttons;
|
||||
GetMouse(&where, &buttons);
|
||||
MovePenTo(where);
|
||||
while (buttons) {
|
||||
|
||||
StrokeLine(where);
|
||||
fMouseSamples.AddItem(new BPoint(where));
|
||||
|
||||
snooze(20000);
|
||||
GetMouse(&where, &buttons);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// main
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
BApplication app("application/x.vnd-Haiku.BitmapBounds");
|
||||
|
||||
BRect frame(50.0, 50.0, 300.0, 250.0);
|
||||
BWindow* window = new BWindow(frame, "Bitmap Bounds", B_TITLED_WINDOW,
|
||||
B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE);
|
||||
|
||||
BView* view = new TestView(window->Bounds(), "test",
|
||||
B_FOLLOW_ALL, B_WILL_DRAW);
|
||||
window->AddChild(view);
|
||||
|
||||
window->Show();
|
||||
|
||||
app.Run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
../../../../../generated/tests/libbe_test/x86/apps/run_haiku_registrar || exit
|
||||
|
||||
if test -f ../../../../../generated/tests/libbe_test/x86/apps/haiku_app_server; then
|
||||
../../../../../generated/tests/libbe_test/x86/apps/haiku_app_server &
|
||||
else
|
||||
echo "You need to \"TARGET_PLATFORM=r5 jam install-test-apps\" first."
|
||||
fi
|
||||
|
||||
sleep 1s
|
||||
|
||||
if test -f ../../../../../generated/tests/libbe_test/x86/apps/LaggingGetMouse; then
|
||||
../../../../../generated/tests/libbe_test/x86/apps/LaggingGetMouse
|
||||
else
|
||||
echo "You need to \"TARGET_PLATFORM=r5 jam install-test-apps\" first."
|
||||
fi
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
SubDir HAIKU_TOP src tests servers app statusbar ;
|
||||
|
||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
AddSubDirSupportedPlatforms libbe_test ;
|
||||
|
||||
UseHeaders [ FDirName os app ] ;
|
||||
UseHeaders [ FDirName os interface ] ;
|
||||
|
||||
SimpleTest StatusBar :
|
||||
main.cpp
|
||||
: be ;
|
||||
|
||||
if ( $(TARGET_PLATFORM) = libbe_test ) {
|
||||
HaikuInstall install-test-apps : $(HAIKU_APP_TEST_DIR) : StatusBar
|
||||
: tests!apps ;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include <Application.h>
|
||||
#include <Directory.h>
|
||||
#include <Entry.h>
|
||||
#include <Message.h>
|
||||
#include <MessageRunner.h>
|
||||
#include <Messenger.h>
|
||||
#include <StatusBar.h>
|
||||
#include <Window.h>
|
||||
|
||||
enum {
|
||||
MSG_PULSE = 'puls'
|
||||
};
|
||||
|
||||
class Window : public BWindow {
|
||||
public:
|
||||
Window(BRect frame)
|
||||
: BWindow(frame, "BStatusBar Test", B_TITLED_WINDOW_LOOK,
|
||||
B_NORMAL_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS
|
||||
| B_QUIT_ON_WINDOW_CLOSE | B_NOT_ZOOMABLE),
|
||||
fHomeFolderEntryCount(0),
|
||||
fHomeFolderCurrentEntry(0)
|
||||
{
|
||||
frame = Bounds();
|
||||
BView* background = new BView(frame, "bg", B_FOLLOW_ALL, 0);
|
||||
background->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
AddChild(background);
|
||||
|
||||
frame = background->Bounds();
|
||||
frame.InsetBy(10, 10);
|
||||
fStatusBar = new BStatusBar(frame, "status", "Label: ", "-Trailing");
|
||||
fStatusBar->SetResizingMode(B_FOLLOW_ALL);
|
||||
background->AddChild(fStatusBar);
|
||||
|
||||
fHomeFolder.SetTo("/boot/home/");
|
||||
BEntry entry;
|
||||
while (fHomeFolder.GetNextEntry(&entry) == B_OK)
|
||||
fHomeFolderEntryCount++;
|
||||
|
||||
fPulse = new BMessageRunner(BMessenger(this),
|
||||
new BMessage(MSG_PULSE), 1000000);
|
||||
}
|
||||
|
||||
~Window()
|
||||
{
|
||||
delete fPulse;
|
||||
}
|
||||
|
||||
virtual void MessageReceived(BMessage* message)
|
||||
{
|
||||
switch (message->what) {
|
||||
case MSG_PULSE: {
|
||||
BEntry entry;
|
||||
if (fHomeFolder.GetNextEntry(&entry) < B_OK) {
|
||||
fHomeFolderCurrentEntry = 0;
|
||||
fHomeFolder.Rewind();
|
||||
fStatusBar->Reset("Label: ", "-Trailing");
|
||||
if (fHomeFolder.GetNextEntry(&entry) < B_OK)
|
||||
break;
|
||||
} else
|
||||
fHomeFolderCurrentEntry++;
|
||||
char name[B_FILE_NAME_LENGTH];
|
||||
if (entry.GetName(name) < B_OK)
|
||||
break;
|
||||
float value = 100.0 * fHomeFolderCurrentEntry
|
||||
/ (fHomeFolderEntryCount - 1);
|
||||
fStatusBar->SetTo(value, "Text", name);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BWindow::MessageReceived(message);
|
||||
}
|
||||
}
|
||||
private:
|
||||
BStatusBar* fStatusBar;
|
||||
BDirectory fHomeFolder;
|
||||
int32 fHomeFolderEntryCount;
|
||||
int32 fHomeFolderCurrentEntry;
|
||||
BMessageRunner* fPulse;
|
||||
};
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
BApplication app("application/x-vnd.stippi.statusbar_test");
|
||||
|
||||
BRect frame(50, 50, 350, 350);
|
||||
Window* window = new Window(frame);
|
||||
window->Show();
|
||||
|
||||
app.Run();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
../../../../../generated/tests/libbe_test/x86/apps/run_haiku_registrar || exit
|
||||
|
||||
if test -f ../../../../../generated/tests/libbe_test/x86/apps/haiku_app_server; then
|
||||
../../../../../generated/tests/libbe_test/x86/apps/haiku_app_server &
|
||||
else
|
||||
echo "You need to \"TARGET_PLATFORM=r5 jam install-test-apps\" first."
|
||||
fi
|
||||
|
||||
sleep 1s
|
||||
|
||||
if test -f ../../../../../generated/tests/libbe_test/x86/apps/StatusBar; then
|
||||
../../../../../generated/tests/libbe_test/x86/apps/StatusBar
|
||||
else
|
||||
echo "You need to \"TARGET_PLATFORM=r5 jam install-test-apps\" first."
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user