bool FileStream::length(int& aLength) const { TEST(isOpen()); int oldpos; LTEST(oldpos = lseek(mFd, 0, SEEK_CUR)); LTEST(aLength = lseek(mFd, 0, SEEK_END)); LTEST(lseek(mFd, oldpos, SEEK_SET)); return true; }
void run_cursor_tests(LiteWindow *window) { /* hide cursor */ LTEST("Hide Cursor", lite_hide_cursor()); sleep(1); /* show cursor */ LTEST("Show cursor", lite_show_cursor()); }
bool FileStream::mTime(time_t& t) const { TEST(isOpen()); struct stat s; LTEST(fstat(mFd, &s)); t = s.st_mtime; return true; };
int main (int argc, char *argv[]) { LiteWindow *window; LiteLabel *label; DFBRectangle rect; int timeout = 0; if (argc > 1) { if ( (strcmp(argv[1], "timeout") == 0) ) timeout = TIMEOUT; } ltest_start_timer("Init LiTE"); if( lite_open(&argc, &argv) ) return 1; ltest_stop_timer(); rect.x = 0; rect.y = 0; rect.w = 800; rect.h = 480; ltest_start_timer("New Window"); LTEST("New Window", lite_new_window(NULL, &rect, DWCAPS_ALPHACHANNEL, liteDefaultWindowTheme, "LiteWindow test", &window)); ltest_stop_timer(); ltest_start_timer("Set Opacities in Window"); LTEST("Set Window Some Opacity", lite_set_window_opacity(window, 0x99)); LTEST("Set Window No Opacity", lite_set_window_opacity(window, liteNoWindowOpacity)); LTEST("Set Window Full Opacity", lite_set_window_opacity(window, liteFullWindowOpacity)); ltest_stop_timer(); rect.x = 10; rect.y = 10; rect.w = 400; ltest_start_timer("New Label and set Text"); LTEST("New Label", lite_new_label(LITE_BOX(window), &rect, liteNoLabelTheme, 20, &label)); LTEST("Set Label Text", lite_set_label_text(label, "Testing LiteWindow")); ltest_stop_timer(); ltest_display_timestamps(); lite_window_event_loop(window, timeout); LTEST("Destroy Window", lite_destroy_window(window)); LTEST("Close LiTE", lite_close()); ltest_print_timestamps(); return 0; }
bool FileStream::seek(Seek::Enum mode, int offset) { TEST(isOpen()); int lm; switch(mode) { case Seek::Start: lm = SEEK_SET; break; case Seek::Current: lm = SEEK_CUR; break; case Seek::End: lm = SEEK_END; break; default: DEBIG_PHAT_ERROR; } LTEST(lseek(mFd, offset, lm)); return true; }
bool FileStream::read(void* dst, int size) { TEST(isOpen()); byte* pos = (byte*)dst; byte* end = pos + size; while(pos != end) { int len = end - pos; int res = ::read(mFd, pos, len); if(res == 0) { LOG("Unexpected EOF.\n"); FAIL; } LTEST(res); DEBUG_ASSERT(res <= len); pos += res; } return true; }
bool WriteFileStream::write(const void* src, int size) { TEST(isOpen()); const byte* pos = (const byte*)src; const byte* end = pos + size; while(pos != end) { int len = end - pos; int res = ::write(mFd, pos, len); if(res == 0) { LOG("Unexpected EOF.\n"); FAIL; } LTEST(res); DEBUG_ASSERT(res <= len); pos += res; } return true; }
void run_slider_tests(LiteWindow *window) { DFBRectangle rect; LiteSlider *slider; /* create a new slider */ rect.x = 50; rect.y = 100; rect.w = 300; rect.h = 20; LTEST("Create Slider", lite_new_slider(LITE_BOX(window), &rect, liteNoSliderTheme, &slider)); /* set slider position */ LTEST("Set Slider Position rightmost", lite_set_slider_pos(slider, 1.0f)); LTEST("Set Slider Position leftmost", lite_set_slider_pos(slider, 0.0f)); LTEST("Set Slider Position over 1.0f", lite_set_slider_pos(slider, 200.0f)); LTEST("Set Slider Position under 0.0f", lite_set_slider_pos(slider, -200.0f)); LTEST("Set Slider Position 0.5f (halfway)", lite_set_slider_pos(slider, 0.5f)); }
bool WriteFileStream::truncate(int size) { TEST(isOpen()); LTEST(ftruncate(mFd, size)); return true; }
bool FileStream::tell(int& aPos) const { TEST(isOpen()); LTEST(aPos = lseek(mFd, 0, SEEK_CUR)); return true; }