├── .gitignore ├── CMakeLists.txt ├── LICENSE ├── README.md ├── cmake ├── functions.cmake ├── modules │ ├── FindEGL.cmake │ ├── FindFFMPEG.cmake │ ├── FindFontConfig.cmake │ ├── FindGLES2.cmake │ ├── FindGLFW.cmake │ ├── FindLibInput.cmake │ ├── FindOpenImageIO.cmake │ ├── FindSystemd.cmake │ ├── FindV4L.cmake │ ├── FindWayland.cmake │ └── FindXKBCommon.cmake └── tests │ ├── avx.c │ └── avx2.c ├── docs ├── CMakeLists.txt ├── doxygen │ ├── Doxyfile.in │ ├── DoxygenLayout.xml │ ├── bootstrap.js │ ├── customdoxygen.css │ ├── directories.dox │ ├── footer.html │ ├── guides.dox │ ├── header.html │ ├── modules.dox │ └── namespaces.dox ├── latex │ ├── CMakeLists.txt │ ├── architecture.tex │ ├── common.tex │ ├── main-loop.tex │ ├── push-button.tex │ └── signal-slot.tex └── wiztk │ ├── build.md │ ├── coding_style.md │ ├── delegates.md │ ├── ide.md │ ├── resources.md │ └── signals_and_slots.md ├── examples ├── CMakeLists.txt ├── capture.cpp ├── eventdemo.cpp ├── frameless.cpp ├── hello.cpp ├── player.cpp ├── simple-egl.cpp ├── simple-shm.cpp ├── theme.cpp └── vulkan-triangle.cpp ├── include └── wiztk │ ├── async │ ├── event-loop.hpp │ ├── message-queue.hpp │ ├── message.hpp │ ├── scheduler.hpp │ └── type.hpp │ ├── base │ ├── abstract-callable.hpp │ ├── abstract-runnable.hpp │ ├── binode.hpp │ ├── bit.hpp │ ├── clamp.hpp │ ├── color.hpp │ ├── counted-deque.hpp │ ├── delegate.hpp │ ├── deque.hpp │ ├── dynamic-library.hpp │ ├── exception.hpp │ ├── macros.hpp │ ├── memory │ │ ├── abstract-ref-counted.hpp │ │ ├── atomic-ref-count.hpp │ │ ├── ref-count.hpp │ │ ├── ref-counted-base.hpp │ │ ├── ref-counted-thread-safe-base.hpp │ │ ├── shared-ptr.hpp │ │ ├── singleton.hpp │ │ └── weak-ptr.hpp │ ├── object.hpp │ ├── point.hpp │ ├── property.hpp │ ├── rect.hpp │ ├── sigcxx.hpp │ ├── size.hpp │ ├── string.hpp │ ├── thickness.hpp │ ├── trace.hpp │ ├── types.hpp │ └── vector.hpp │ ├── config.hpp.in │ ├── device │ └── video │ │ └── camera.hpp │ ├── graphics │ ├── alignment.hpp │ ├── bitmap.hpp │ ├── canvas.hpp │ ├── clip-operation.hpp │ ├── color-space.hpp │ ├── font-style.hpp │ ├── font.hpp │ ├── gradient-shader.hpp │ ├── image-info.hpp │ ├── image.hpp │ ├── matrix.hpp │ ├── paint.hpp │ ├── path.hpp │ ├── pixmap.hpp │ ├── shader.hpp │ ├── surface-props.hpp │ ├── surface.hpp │ ├── text-alignment.hpp │ └── typeface.hpp │ ├── gui │ ├── abstract-button.hpp │ ├── abstract-egl-backend.hpp │ ├── abstract-epoll-task.hpp │ ├── abstract-event-handler.hpp │ ├── abstract-layout.hpp │ ├── abstract-rendering-api.hpp │ ├── abstract-rendering-backend.hpp │ ├── abstract-shell-view.hpp │ ├── abstract-slider.hpp │ ├── abstract-view.hpp │ ├── anchor-group.hpp │ ├── anchor.hpp │ ├── application.hpp │ ├── buffer.hpp │ ├── callback.hpp │ ├── context.hpp │ ├── cursor.hpp │ ├── dialog.hpp │ ├── display.hpp │ ├── gl-view.hpp │ ├── gl-window.hpp │ ├── gles2-backend.hpp │ ├── glesv2-api.hpp │ ├── input-event.hpp │ ├── input-manager.hpp │ ├── input.hpp │ ├── key-event.hpp │ ├── label.hpp │ ├── linear-layout.hpp │ ├── main-loop.hpp │ ├── main-window.hpp │ ├── mouse-event.hpp │ ├── output-manager.hpp │ ├── output.hpp │ ├── push-button.hpp │ ├── queued-task.hpp │ ├── region.hpp │ ├── relative-layout.hpp │ ├── shared-memory-pool.hpp │ ├── slider.hpp │ ├── spinner.hpp │ ├── surface.hpp │ ├── theme.hpp │ ├── timer.hpp │ ├── title-bar.hpp │ ├── tooltip.hpp │ ├── touch-event.hpp │ ├── video-view.hpp │ ├── vulkan-api.hpp │ └── window.hpp │ ├── net │ ├── address-family.hpp │ ├── address-info.hpp │ ├── io-buffer.hpp │ ├── ip-address.hpp │ ├── protocol-type.hpp │ ├── server-socket.hpp │ ├── socket-exception.hpp │ ├── socket-type.hpp │ └── socket.hpp │ └── system │ ├── logging │ ├── logger.hpp │ └── type.hpp │ ├── threading │ ├── main-thread.hpp │ ├── mutex.hpp │ ├── thread-local.hpp │ └── thread.hpp │ └── time │ ├── clock.hpp │ ├── delta.hpp │ ├── realtime-clock.hpp │ └── timer.hpp ├── scripts ├── download.py └── install-dependencies.sh ├── src ├── CMakeLists.txt └── wiztk │ ├── CMakeLists.txt │ ├── async │ ├── CMakeLists.txt │ ├── event-loop.cpp │ ├── event-loop │ │ ├── private.cpp │ │ ├── private.hpp │ │ ├── quit-event.cpp │ │ └── quit-event.hpp │ ├── message-queue.cpp │ └── scheduler.cpp │ ├── base │ ├── CMakeLists.txt │ ├── binode.cpp │ ├── counted-deque.cpp │ ├── dynamic-library.cpp │ ├── object.cpp │ ├── sigcxx.cpp │ ├── string.cpp │ └── trace.cpp │ ├── device │ ├── CMakeLists.txt │ └── video │ │ └── camera.cpp │ ├── graphics │ ├── CMakeLists.txt │ ├── bitmap.cpp │ ├── bitmap │ │ └── private.hpp │ ├── canvas.cpp │ ├── canvas │ │ ├── native.hpp │ │ └── private.hpp │ ├── color-space.cpp │ ├── color-space │ │ └── private.hpp │ ├── font-style.cpp │ ├── font-style │ │ └── private.hpp │ ├── font.cpp │ ├── font │ │ └── private.hpp │ ├── gradient-shader.cpp │ ├── image-info.cpp │ ├── image-info │ │ └── private.hpp │ ├── image.cpp │ ├── image │ │ └── private.hpp │ ├── matrix.cpp │ ├── matrix │ │ └── private.hpp │ ├── paint.cpp │ ├── paint │ │ └── private.hpp │ ├── path.cpp │ ├── path │ │ └── private.hpp │ ├── pixmap.cpp │ ├── pixmap │ │ └── private.hpp │ ├── shader.cpp │ ├── shader │ │ └── private.hpp │ ├── surface-props.cpp │ ├── surface-props │ │ └── private.hpp │ ├── surface.cpp │ ├── surface │ │ └── private.hpp │ ├── typeface.cpp │ └── typeface │ │ └── private.hpp │ ├── gui │ ├── CMakeLists.txt │ ├── abstract-button.cpp │ ├── abstract-egl-backend.cpp │ ├── abstract-egl-backend │ │ └── private.hpp │ ├── abstract-event-handler.cpp │ ├── abstract-event-handler │ │ └── private.hpp │ ├── abstract-layout.cpp │ ├── abstract-rendering-api.cpp │ ├── abstract-rendering-api_private.hpp │ ├── abstract-rendering-api_proxy.hpp │ ├── abstract-rendering-backend.cpp │ ├── abstract-shell-view.cpp │ ├── abstract-shell-view │ │ ├── private.cpp │ │ └── private.hpp │ ├── abstract-view.cpp │ ├── abstract-view │ │ ├── iterators.hpp │ │ └── private.hpp │ ├── anchor-group.cpp │ ├── anchor.cpp │ ├── application.cpp │ ├── buffer.cpp │ ├── buffer │ │ ├── private.cpp │ │ └── private.hpp │ ├── callback.cpp │ ├── cursor.cpp │ ├── dialog.cpp │ ├── display.cpp │ ├── display │ │ ├── private.cpp │ │ └── private.hpp │ ├── gl-view.cpp │ ├── gl-window.cpp │ ├── gles2-backend.cpp │ ├── gles2-backend │ │ ├── private.cpp │ │ └── private.hpp │ ├── glesv2-api.cpp │ ├── input-event.cpp │ ├── input-manager.cpp │ ├── input.cpp │ ├── input │ │ ├── private.cpp │ │ └── private.hpp │ ├── keyboard_state.cpp │ ├── keyboard_state.hpp │ ├── keymap.cpp │ ├── keymap.hpp │ ├── label.cpp │ ├── linear-layout.cpp │ ├── main-loop.cpp │ ├── main-loop │ │ ├── display-event.cpp │ │ ├── display-event.hpp │ │ ├── private.cpp │ │ ├── private.hpp │ │ ├── signal-event.cpp │ │ └── signal-event.hpp │ ├── main-window.cpp │ ├── mouse-event.cpp │ ├── mouse-event │ │ └── private.hpp │ ├── output-manager.cpp │ ├── output.cpp │ ├── output │ │ ├── private.cpp │ │ └── private.hpp │ ├── push-button.cpp │ ├── region.cpp │ ├── relative-layout.cpp │ ├── shared-memory-pool.cpp │ ├── slider.cpp │ ├── spinner.cpp │ ├── surface.cpp │ ├── surface │ │ ├── private.cpp │ │ ├── private.hpp │ │ └── shell │ │ │ ├── popup │ │ │ └── private.hpp │ │ │ ├── private.cpp │ │ │ ├── private.hpp │ │ │ └── toplevel │ │ │ ├── private.cpp │ │ │ └── private.hpp │ ├── theme-dark.cpp │ ├── theme-dark.hpp │ ├── theme-light.cpp │ ├── theme-light.hpp │ ├── theme.cpp │ ├── timer.cpp │ ├── title-bar.cpp │ ├── tooltip.cpp │ ├── video-view.cpp │ ├── vulkan-api.cpp │ └── window.cpp │ ├── net │ ├── CMakeLists.txt │ ├── address-info.cpp │ ├── address-info │ │ └── private.hpp │ ├── io-buffer.cpp │ ├── ip-address.cpp │ ├── ip-address │ │ ├── native.cpp │ │ ├── native.hpp │ │ ├── private.cpp │ │ └── private.hpp │ ├── server-socket.cpp │ └── socket.cpp │ └── system │ ├── CMakeLists.txt │ ├── logging │ └── logger.cpp │ ├── threading │ ├── main-thread.cpp │ ├── mutex.cpp │ ├── thread.cpp │ └── thread │ │ ├── private.cpp │ │ └── private.hpp │ └── time │ ├── clock.cpp │ ├── delta.cpp │ ├── realtime-clock.cpp │ └── timer.cpp └── test ├── CMakeLists.txt └── wiztk ├── CMakeLists.txt ├── async ├── CMakeLists.txt └── event-loop │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test-event-loop.cpp │ └── test-event-loop.hpp ├── base ├── CMakeLists.txt ├── color │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test-color.cpp │ └── test-color.hpp ├── counted-deque │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test-counted-deque.cpp │ └── test-counted-deque.hpp ├── delegate │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test-delegate.cpp │ └── test-delegate.hpp ├── deque │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test-deque.cpp │ └── test-deque.hpp ├── margin │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test.cpp │ └── test.hpp ├── memory │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test-ref-counted-base.cpp │ ├── test-ref-counted-base.hpp │ ├── test-shared-ptr.cpp │ ├── test-shared-ptr.hpp │ ├── test-singleton.cpp │ ├── test-singleton.hpp │ ├── test-weak-ptr.cpp │ └── test-weak-ptr.hpp ├── object │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test.cpp │ └── test.hpp ├── rect │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test.cpp │ └── test.hpp ├── sigcxx │ ├── CMakeLists.txt │ ├── main.cpp │ ├── observer.cpp │ ├── observer.hpp │ ├── subject.cpp │ ├── subject.hpp │ ├── trackable-test.cpp │ └── trackable-test.hpp ├── string │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test-string-piece.cpp │ ├── test-string-piece.hpp │ ├── test-string.cpp │ └── test-string.hpp ├── trace │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test.cpp │ └── test.hpp └── vectors │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test.cpp │ └── test.hpp ├── device ├── CMakeLists.txt └── video │ └── camera │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test-camera.cpp │ └── test-camera.hpp ├── graphics ├── CMakeLists.txt ├── canvas │ ├── CMakeLists.txt │ ├── draw-test.cpp │ ├── draw-test.hpp │ ├── flush-test.cpp │ ├── flush-test.hpp │ ├── lock-guard-test.cpp │ ├── lock-guard-test.hpp │ ├── main.cpp │ ├── matrix-test.cpp │ ├── matrix-test.hpp │ ├── stack-test.cpp │ └── stack-test.hpp ├── color-space │ ├── CMakeLists.txt │ ├── color-space-test.cpp │ ├── color-space-test.hpp │ └── main.cpp ├── font-style │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test.cpp │ └── test.hpp ├── font │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test.cpp │ └── test.hpp ├── gradient-shader │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test.cpp │ └── test.hpp ├── image-info │ ├── CMakeLists.txt │ ├── image-info-test.cpp │ ├── image-info-test.hpp │ └── main.cpp ├── paint │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test.cpp │ └── test.hpp ├── path │ ├── CMakeLists.txt │ ├── main.cpp │ ├── path-test.cpp │ └── path-test.hpp └── typeface │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test.cpp │ └── test.hpp ├── gui ├── CMakeLists.txt ├── application │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test.cpp │ └── test.hpp ├── dialog │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test.cpp │ └── test.hpp ├── display │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test.cpp │ └── test.hpp ├── gl-view │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test.cpp │ └── test.hpp ├── gles2-backend │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test-gles2-backend.cpp │ └── test-gles2-backend.hpp ├── linear-layout │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test.cpp │ └── test.hpp ├── output │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test-output.cpp │ └── test-output.hpp ├── relative-layout │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test.cpp │ └── test.hpp ├── slider │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test.cpp │ └── test.hpp ├── timer │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test.cpp │ └── test.hpp └── window │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test.cpp │ └── test.hpp ├── net ├── CMakeLists.txt ├── address-info │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test-address-info.cpp │ └── test-address-info.hpp ├── ip-address │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test-ip-address.cpp │ └── test-ip-address.hpp ├── server-socket │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test-server-socket.cpp │ └── test-server-socket.hpp └── socket │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test-socket.cpp │ └── test-socket.hpp └── system ├── CMakeLists.txt ├── logging ├── CMakeLists.txt └── logger │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test-logger.cpp │ └── test-logger.hpp ├── threading ├── CMakeLists.txt ├── thread-local │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test-thread-local.cpp │ └── test-thread-local.hpp └── thread │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test-thread.cpp │ └── test-thread.hpp └── time ├── CMakeLists.txt ├── clock ├── CMakeLists.txt ├── main.cpp ├── test-clock.cpp └── test-clock.hpp └── timer ├── CMakeLists.txt ├── main.cpp ├── test-timer.cpp └── test-timer.hpp /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | /.idea/ 34 | /cmake-build-debug/ 35 | /build/ 36 | 37 | # Header file generated by CMake 38 | /include/wiztk/config.hpp 39 | 40 | /.vscode/ 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WizTK Framework 2 | 3 | **Warning: This project is still very much a work in progress and under heavy 4 | development. Support cannot be guaranteed and it may not function as you 5 | expect.** 6 | 7 | ---- 8 | 9 | ## What is WizTK? 10 | 11 | **WizTK** is a simple C++ GUI toolkit for Linux only, based on [Google 12 | Skia](https://skia.org) and [Wayland](https://wayland.freedesktop.org), 13 | originally for my own purpose. 14 | 15 | ![Example Windows In Fedora 16 | 26](https://github.com/wiztk/pool/blob/master/screenshots/examples.png) 17 | 18 | ## Build the source code 19 | 20 | See [Build the source code](docs/wiztk/build.md). 21 | 22 | **More details will be described later...** 23 | -------------------------------------------------------------------------------- /cmake/modules/FindGLES2.cmake: -------------------------------------------------------------------------------- 1 | # Find GLES2 2 | # 3 | # GLES2_INCLUDE_DIRS 4 | # GLES2_LIBRARIES 5 | # GLES2_FOUND 6 | 7 | find_package(PkgConfig) 8 | 9 | pkg_check_modules(PC_GLES2 glesv2) 10 | 11 | if (PC_GLES2_FOUND) 12 | set(GLES2_DEFINITIONS ${PC_GLES2_CFLAGS} ${PC_GLES2_CFLAGS_OTHER}) 13 | endif () 14 | 15 | find_path(GLES2_INCLUDE_DIRS NAMES "GLES2/gl2.h" 16 | HINTS ${PC_GLES2_INCLUDEDIR} ${PC_GLES2_INCLUDE_DIRS}) 17 | 18 | find_library(GLES2_LIBRARIES NAMES "GLESv2" 19 | HINTS ${PC_GLES2_LIBDIR} ${PC_GLES2_LIBRARY_DIRS}) 20 | 21 | include(FindPackageHandleStandardArgs) 22 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLES2 DEFAULT_MSG GLES2_INCLUDE_DIRS GLES2_LIBRARIES) 23 | 24 | mark_as_advanced(GLES2_INCLUDE_DIRS GLES2_LIBRARIES) 25 | -------------------------------------------------------------------------------- /cmake/modules/FindGLFW.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Try to find GLFW library and include path. 3 | # Once done this will define 4 | # 5 | # GLFW_FOUND 6 | # GLFW_INCLUDE_DIR 7 | # GLFW_LIBRARIES 8 | # 9 | 10 | if(NOT GLFW_FOUND) 11 | 12 | FIND_PATH(GLFW_INCLUDE_DIR GLFW/glfw3.h 13 | PATHS 14 | /usr/local/include 15 | /usr/X11/include 16 | /usr/include 17 | /opt/local/include 18 | NO_DEFAULT_PATH 19 | ) 20 | 21 | FIND_LIBRARY( GLFW_LIBRARIES NAMES glfw glfw3 22 | PATHS 23 | /usr/local 24 | /usr/X11 25 | /usr 26 | PATH_SUFFIXES 27 | a 28 | lib64 29 | lib 30 | NO_DEFAULT_PATH 31 | ) 32 | 33 | SET(GLFW_FOUND "NO") 34 | IF (GLFW_INCLUDE_DIR AND GLFW_LIBRARIES) 35 | SET(GLFW_FOUND "YES") 36 | ENDIF (GLFW_INCLUDE_DIR AND GLFW_LIBRARIES) 37 | 38 | if(GLFW_FOUND) 39 | message(STATUS "Found GLFW: ${GLFW_INCLUDE_DIR}") 40 | else(GLFW_FOUND) 41 | message(FATAL_ERROR "could NOT find GLFW") 42 | endif(GLFW_FOUND) 43 | 44 | endif(NOT GLFW_FOUND) 45 | -------------------------------------------------------------------------------- /cmake/modules/FindSystemd.cmake: -------------------------------------------------------------------------------- 1 | # Try to find systemd 2 | 3 | find_package(PkgConfig QUIET) 4 | pkg_check_modules(PC_SYSTEMD QUIET libsystemd) 5 | 6 | find_path(SYSTEMD_INCLUDE_DIR NAMES systemd/sd-daemon.h HINTS ${PC_SYSTEMD_INCLUDE_DIRS}) 7 | find_library(SYSTEMD_LIBRARY NAMES systemd HINTS ${PC_SYSTEMD_LIBRARY_DIRS}) 8 | 9 | include(FindPackageHandleStandardArgs) 10 | 11 | find_package_handle_standard_args( 12 | SYSTEMD 13 | REQUIRED_VARS 14 | SYSTEMD_LIBRARY 15 | SYSTEMD_INCLUDE_DIR 16 | ) 17 | 18 | mark_as_advanced(SYSTEMD_INCLUDE_DIR SYSTEMD_LIBRARY) 19 | 20 | set(SYSTEMD_INCLUDE_DIRS ${SYSTEMD_INCLUDE_DIR}) 21 | set(SYSTEMD_LIBRARIES ${SYSTEMD_LIBRARY}) 22 | -------------------------------------------------------------------------------- /cmake/modules/FindV4L.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # - Find the V4L include file and library 3 | # 4 | # V4L_FOUND - system has V4L 5 | # V4L_INCLUDE_DIRS - the V4L include directory 6 | # V4L_LIBRARIES - The libraries needed to use V4L 7 | 8 | find_package(PkgConfig) 9 | 10 | pkg_check_modules(V4L_PKG QUIET libv4l2) 11 | 12 | find_path( 13 | V4L_INCLUDE_DIR 14 | NAMES libv4l2.h 15 | PATHS /usr/local/include /usr/include 16 | HINTS ${V4L_PKG_INCLUDE_DIRS} 17 | ) 18 | 19 | find_library( 20 | V4L_LIBRARY 21 | NAMES v4l2 ${V4L_PKG_LIBRARY} 22 | PATHS /usr/local /usr 23 | HINTS ${V4L_PKG_LIBRARY_DIRS} 24 | PATH_SUFFIXES lib64 lib 25 | ) 26 | 27 | include(FindPackageHandleStandardArgs) 28 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(V4L DEFAULT_MSG V4L_LIBRARY V4L_INCLUDE_DIR ) 29 | 30 | mark_as_advanced(V4L_INCLUDE_DIR V4L_LIBRARY) 31 | -------------------------------------------------------------------------------- /cmake/modules/FindXKBCommon.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find XKBCommon 2 | # Once done, this will define 3 | # 4 | # XKBCOMMON_FOUND - System has XKBCommon 5 | # XKBCOMMON_INCLUDE_DIRS - The XKBCommon include directories 6 | # XKBCOMMON_LIBRARIES - The libraries needed to use XKBCommon 7 | # XKBCOMMON_DEFINITIONS - Compiler switches required for using XKBCommon 8 | 9 | find_package(PkgConfig) 10 | pkg_check_modules(PC_XKBCOMMON QUIET xkbcommon) 11 | set(XKBCOMMON_DEFINITIONS ${PC_XKBCOMMON_CFLAGS_OTHER}) 12 | 13 | find_path(XKBCOMMON_INCLUDE_DIR 14 | NAMES xkbcommon/xkbcommon.h 15 | HINTS ${PC_XKBCOMMON_INCLUDE_DIR} ${PC_XKBCOMMON_INCLUDE_DIRS} 16 | ) 17 | 18 | find_library(XKBCOMMON_LIBRARY 19 | NAMES xkbcommon 20 | HINTS ${PC_XKBCOMMON_LIBRARY} ${PC_XKBCOMMON_LIBRARY_DIRS} 21 | ) 22 | 23 | set(XKBCOMMON_LIBRARIES ${XKBCOMMON_LIBRARY}) 24 | set(XKBCOMMON_LIBRARY_DIRS ${XKBCOMMON_LIBRARY_DIRS}) 25 | set(XKBCOMMON_INCLUDE_DIRS ${XKBCOMMON_INCLUDE_DIR}) 26 | 27 | include(FindPackageHandleStandardArgs) 28 | find_package_handle_standard_args(XKBCommon DEFAULT_MSG 29 | XKBCOMMON_LIBRARY 30 | XKBCOMMON_INCLUDE_DIR 31 | ) 32 | 33 | mark_as_advanced(XKBCOMMON_LIBRARY XKBCOMMON_INCLUDE_DIR) 34 | 35 | -------------------------------------------------------------------------------- /cmake/tests/avx.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file A simple C source to detect Intel SIMD 256-bit avx instruction support 3 | * 4 | * Try to compile with: 5 | * 6 | * gcc -mavx avx.c 7 | */ 8 | 9 | #include 10 | 11 | int main(int argc, char **argv) { 12 | __m256d a; 13 | __m256d b; 14 | __m256d ret = _mm256_add_pd(a, b); 15 | 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /cmake/tests/avx2.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file A simple C source to detect Intel SIMD 256-bit avx2 instruction support 3 | * 4 | * Try to compile with: 5 | * 6 | * gcc -mavx2 avx2.c 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | int main(int argc, char **argv) { 13 | __m256i x; 14 | __m256i y; 15 | __m256i ret = _mm256_mpsadbw_epu8(x, y, 0); 16 | 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /docs/doxygen/directories.dox: -------------------------------------------------------------------------------- 1 | /** 2 | * @dir include/wiztk 3 | * @brief Directory for public header files of this project. 4 | */ 5 | 6 | /** 7 | * @dir include/wiztk/base 8 | * @brief Header files in 'base' module. 9 | */ 10 | 11 | /** 12 | * @dir include/wiztk/base/memory 13 | * @brief Header files of memory management. 14 | */ 15 | 16 | /** 17 | * @dir include/wiztk/system 18 | * @brief Header files in 'system' module. 19 | */ 20 | 21 | /** 22 | * @dir include/wiztk/gui 23 | * @brief Header files in 'gui' module. 24 | */ 25 | -------------------------------------------------------------------------------- /docs/doxygen/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 15 | 16 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /docs/doxygen/guides.dox: -------------------------------------------------------------------------------- 1 | /** 2 | * @page guides Guides 3 | * @tableofcontents 4 | * 5 | * @section start Start 6 | * 7 | * - [Get the code: checkout, build and run](md_docs_wiztk_build.html) 8 | * - [IDE Configuration](md_doc_wiztk_ide.html) 9 | * - Directory structure 10 | * 11 | * @section tutorial Tutorial 12 | * 13 | * - A "Hello World" example 14 | * 15 | * @section guide Development Guides 16 | * 17 | * - C++11 18 | * - [Coding style](md_docs_wiztk_coding_style.html) 19 | * - [Fast C++ Delegates](md_docs_wiztk_delegates.html) 20 | * - [Signals and Slots](md_docs_wiztk_signals_and_slots.html) 21 | * - Wayland introduction 22 | * - Surface stack 23 | * - Drawing with Google Skia 24 | * - HiDPI 25 | * - Unit test 26 | */ 27 | -------------------------------------------------------------------------------- /docs/latex/common.tex: -------------------------------------------------------------------------------- 1 | % file: common.tex 2 | % 3 | % Common settings 4 | % 5 | 6 | -------------------------------------------------------------------------------- /docs/wiztk/build.md: -------------------------------------------------------------------------------- 1 | Build the source code 2 | ===================== 3 | 4 | ## Checkout source code 5 | 6 | ```shell 7 | $ git clone --recursive https://github.com/wiztk/framework.git 8 | ``` 9 | 10 | ## Install dependencies 11 | 12 | Use the shell script to install prerequisites if you're using Ubuntu or Fedora: 13 | 14 | ```shell 15 | $ cd 16 | $ ./scripts/install-dependencies.sh 17 | ``` 18 | 19 | ## Build the source code 20 | 21 | Create a temporary directory and generate Makefiles: 22 | 23 | ```shell 24 | $ cd 25 | $ mkdir build 26 | $ cd build 27 | $ cmake .. 28 | ``` 29 | 30 | Run `make` to build the project. 31 | 32 | ```shel 33 | $ make 34 | ``` 35 | 36 | This will build and generate examples in `bin/` and library in `lib/`. 37 | 38 | Available Cmake options: 39 | 40 | - `-DCMAKE_BUILD_TYPE=`: value = 'Release' or 'Debug' 41 | - `-DBUILD_UNIT_TEST=`: value = 'On', 'True', 'Off' or 'False' 42 | 43 | ## Build the document 44 | 45 | ```shell 46 | $ make doc 47 | ``` 48 | 49 | This will generate html document through doxygen in `html/`, open the 50 | `html/index.html` with your favorite web browser. 51 | -------------------------------------------------------------------------------- /docs/wiztk/coding_style.md: -------------------------------------------------------------------------------- 1 | Coding Style 2 | ============ 3 | 4 | This project follows [Google C++ Style 5 | Guide](https://google.github.io/styleguide/cppguide.html). 6 | 7 | 8 | -------------------------------------------------------------------------------- /docs/wiztk/ide.md: -------------------------------------------------------------------------------- 1 | IDE Configuration 2 | ================= 3 | 4 | # [CLion](https://www.jetbrains.com/clion/) 5 | 6 | ## Import Project 7 | 8 | In [Clion](https://www.jetbrains.com/clion/) you can import the project folder 9 | directly. 10 | 11 | ## Configure C/C++ Code Style 12 | 13 | File -> Settings -> Editor -> Code Style -> C/C++ -> Set From... -> Predefined 14 | Style -> Google 15 | -------------------------------------------------------------------------------- /docs/wiztk/resources.md: -------------------------------------------------------------------------------- 1 | Resources 2 | ========= 3 | 4 | - [Khronos](https://www.khronos.org/) 5 | - [OpenMAX](https://www.khronos.org/openmax) 6 | - Books 7 | - [The Linux Programming Interface: A Linux and UNIX System Programming Handbook](https://www.amazon.com/s?ie=UTF8&keywords=The%20Linux%20Programming%20Interface%3A%20A%20Linux%20and%20UNIX%20System%20Programming%20Handbook%20%20%20Michael%20Kerrisk&page=1&rh=n%3A283155%2Ck%3AThe%20Linux%20Programming%20Interface%3A%20A%20Linux%20and%20) 8 | - [Unix Network Programming, Volume 1: The Sockets Networking API (3rd Edition)](https://www.amazon.com/Unix-Network-Programming-Sockets-Networking/dp/0131411551/ref=sr_1_1?s=books&ie=UTF8&qid=1517843764&sr=1-1&keywords=unix+network+programming) 9 | - Articles 10 | - C++ 11 | - [C++ std::thread Event Loop with Message Queue and Timer](https://www.codeproject.com/Articles/1169105/Cplusplus-std-thread-Event-Loop-with-Message-Queue) 12 | - Linux 13 | - [A Tutorial on Using the ALSA Audio API](http://www.equalarea.com/paul/alsa-audio.html) 14 | - [Separation Anxiety: A Tutorial for Isolating Your System with Linux Namespaces](https://www.toptal.com/linux/separation-anxiety-isolating-your-system-with-linux-namespaces) 15 | - Sample code 16 | - [Vulkan in Wayland](https://github.com/krh/vkcube) -------------------------------------------------------------------------------- /examples/hello.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include "wiztk/graphics/font-style.hpp" 23 | 24 | int main(int argc, char *argv[]) { 25 | using namespace wiztk; 26 | using namespace wiztk::gui; 27 | using namespace wiztk::graphics; 28 | 29 | Application app(argc, argv); 30 | 31 | Window win(320, 240, "Hello"); 32 | win.SetAppId("Hello"); 33 | 34 | auto *label = Label::Create("Hello Wayland!"); 35 | label->SetName("Label"); 36 | label->SetForeColor(0xFF444444); 37 | label->SetFont(Font(24.f)); 38 | win.SetContentView(label); 39 | 40 | win.Show(); 41 | 42 | return app.Run(); 43 | } 44 | -------------------------------------------------------------------------------- /examples/simple-shm.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Freeman Zhang 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 | #include "wiztk/gui/application.hpp" 18 | #include "wiztk/gui/window.hpp" 19 | #include "wiztk/gui/spinner.hpp" 20 | 21 | using namespace wiztk; 22 | using namespace wiztk::gui; 23 | 24 | int main(int argc, char *argv[]) { 25 | Application app(argc, argv); 26 | 27 | auto *win = new Window(320, 280, "Simple Shm"); 28 | win->SetAppId("Simple-Shm"); 29 | 30 | auto *widget = Spinner::Create(); 31 | win->SetContentView(widget); 32 | 33 | win->Show(); 34 | 35 | return app.Run(); 36 | } 37 | -------------------------------------------------------------------------------- /examples/vulkan-triangle.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 18-9-27. 3 | // 4 | 5 | #define GLFW_INCLUDE_VULKAN 6 | 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | const int WIDTH = 800; 14 | const int HEIGHT = 600; 15 | 16 | class HelloTriangleApplication { 17 | public: 18 | void run() { 19 | initWindow(); 20 | initVulkan(); 21 | mainLoop(); 22 | cleanup(); 23 | } 24 | 25 | private: 26 | GLFWwindow *window; 27 | 28 | void initWindow() { 29 | glfwInit(); 30 | 31 | glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); 32 | glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE); 33 | 34 | window = glfwCreateWindow(WIDTH, HEIGHT, "Vulkan", nullptr, nullptr); 35 | } 36 | 37 | void initVulkan() { 38 | 39 | } 40 | 41 | void mainLoop() { 42 | while (!glfwWindowShouldClose(window)) { 43 | glfwPollEvents(); 44 | } 45 | } 46 | 47 | void cleanup() { 48 | glfwDestroyWindow(window); 49 | 50 | glfwTerminate(); 51 | } 52 | }; 53 | 54 | int main() { 55 | HelloTriangleApplication app; 56 | 57 | try { 58 | app.run(); 59 | } catch (const std::exception &e) { 60 | std::cerr << e.what() << std::endl; 61 | return EXIT_FAILURE; 62 | } 63 | 64 | return EXIT_SUCCESS; 65 | } 66 | 67 | -------------------------------------------------------------------------------- /include/wiztk/async/type.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #ifndef WIZTK_ASYNC_TYPE_HPP_ 18 | #define WIZTK_ASYNC_TYPE_HPP_ 19 | 20 | #include 21 | 22 | namespace wiztk { 23 | namespace async { 24 | 25 | enum EventType { 26 | 27 | kRead = EPOLLIN, /**< Data other than high-priority data can be read */ 28 | 29 | kPriority = EPOLLPRI, /**< High-priority data can be read */ 30 | 31 | kWrite = EPOLLOUT, /**< Normal data can be written */ 32 | 33 | kShutdown = EPOLLRDHUP, /**< Shutdown on peer socket */ 34 | 35 | kEdgeTriggered = EPOLLET, /**< Employ edge-triggered event notification */ 36 | 37 | kError = EPOLLERR, /**< An error has occurred */ 38 | 39 | kHangup = EPOLLHUP /**< A hangup has occurred */ 40 | 41 | }; 42 | 43 | } // namespace async 44 | } // namespace wiztk 45 | 46 | #endif // WIZTK_ASYNC_TYPE_HPP_ 47 | -------------------------------------------------------------------------------- /include/wiztk/base/bit.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WizTK Authors. 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 | #ifndef WIZTK_BASE_BIT_HPP_ 18 | #define WIZTK_BASE_BIT_HPP_ 19 | 20 | namespace wiztk { 21 | namespace base { 22 | 23 | /** 24 | * @ingroup base 25 | * @brief Helper class for bit operation 26 | */ 27 | class Bit { 28 | 29 | public: 30 | 31 | template 32 | static inline void Set(T &x, T y) { 33 | x |= y; 34 | } 35 | 36 | template 37 | static inline void Clear(T &x, T y) { 38 | x &= ~y; 39 | } 40 | 41 | template 42 | static inline void Inverse(T &x, T y) { 43 | x = (x & (~y)) | (x ^ y); 44 | } 45 | 46 | }; 47 | 48 | } // namespace base 49 | } // namespace wiztk 50 | 51 | #endif // WIZTK_BASE_BIT_HPP_ 52 | -------------------------------------------------------------------------------- /include/wiztk/base/clamp.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WizTK Authors. 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 | #ifndef WIZTK_BASE_CLAMP_HPP_ 18 | #define WIZTK_BASE_CLAMP_HPP_ 19 | 20 | #include 21 | 22 | namespace wiztk { 23 | namespace base { 24 | 25 | /** 26 | * @ingroup base 27 | * @brief Clamp given value between min and max 28 | */ 29 | template 30 | inline T Clamp(T x, T min_value, T max_value) { 31 | return std::min(std::max(x, min_value), max_value); 32 | } 33 | 34 | } // namespace base 35 | } // namespace wiztk 36 | 37 | #endif // WIZTK_BASE_CLAMP_HPP_ 38 | -------------------------------------------------------------------------------- /include/wiztk/base/dynamic-library.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Freeman Zhang 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 | #ifndef WIZTK_BASE_DYNAMIC_LIBRARY_HPP_ 18 | #define WIZTK_BASE_DYNAMIC_LIBRARY_HPP_ 19 | 20 | #include 21 | 22 | namespace wiztk { 23 | namespace base { 24 | 25 | /** 26 | * @ingroup base 27 | * @brief dlopen wrapper 28 | */ 29 | class DynamicLibrary { 30 | 31 | public: 32 | 33 | DynamicLibrary() 34 | : handle_(nullptr) {} 35 | 36 | ~DynamicLibrary(); 37 | 38 | void Open(const char *filename, int flags); 39 | 40 | void Close(); 41 | 42 | void *GetSymbol(const char *symbol); 43 | 44 | bool IsValid() const { return nullptr != handle_; } 45 | 46 | private: 47 | 48 | void *handle_; 49 | 50 | }; 51 | 52 | } // namespace base 53 | } // namespace wiztk 54 | 55 | #endif // WIZTK_BASE_DYNAMIC_LIBRARY_HPP_ 56 | -------------------------------------------------------------------------------- /include/wiztk/base/exception.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Freeman Zhang 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 | #ifndef WIZTK_BASE_EXCEPTIONS_HPP_ 18 | #define WIZTK_BASE_EXCEPTIONS_HPP_ 19 | 20 | #include 21 | 22 | namespace wiztk { 23 | namespace base { 24 | 25 | /** 26 | * @ingroup base 27 | * @brief The basic exception class. 28 | */ 29 | class Exception : public std::exception { 30 | public: 31 | 32 | explicit Exception(const std::string &what_arg) 33 | : msg_(what_arg) {} 34 | 35 | explicit Exception(const char *what_arg) 36 | : msg_(what_arg) {} 37 | 38 | const char *what() const noexcept override { 39 | return msg_.c_str(); 40 | }; 41 | 42 | private: 43 | 44 | std::string msg_; 45 | 46 | }; 47 | 48 | } // namespace base 49 | } // namespace wiztk 50 | 51 | #endif // WIZTK_BASE_EXCEPTIONS_HPP_ 52 | -------------------------------------------------------------------------------- /include/wiztk/config.hpp.in: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | * @file config.hpp 19 | * @brief A global config file generated with cmake. 20 | */ 21 | 22 | #ifndef WIZTK_CONFIG_HPP_ 23 | #define WIZTK_CONFIG_HPP_ 24 | 25 | #define WIZTK_VERSION_MAJOR @VERSION_MAJOR@ 26 | 27 | #define WIZTK_VERSION_MINOR @VERSION_MINOR@ 28 | 29 | #define WIZTK_VERSION_PATCH @VERSION_PATCH@ 30 | 31 | #define WIZTK_VERSION_STRING "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@" 32 | 33 | #define WIZTK_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@" 34 | 35 | #define WIZTK_PROJECT_SOURCE_DIR "@PROJECT_SOURCE_DIR@" 36 | 37 | #define WIZTK_HAVE_SYSTEMD @HAVE_SYSTEMD@ 38 | 39 | #endif // WIZTK_CONFIG_HPP_ 40 | -------------------------------------------------------------------------------- /include/wiztk/device/video/camera.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #ifndef WIZTK_DEVICE_VIDEO_CAMERA_HPP_ 18 | #define WIZTK_DEVICE_VIDEO_CAMERA_HPP_ 19 | 20 | #include "wiztk/base/macros.hpp" 21 | 22 | namespace wiztk { 23 | namespace device { 24 | namespace video { 25 | 26 | class WIZTK_EXPORT Camera { 27 | 28 | public: 29 | 30 | Camera(); 31 | 32 | ~Camera(); 33 | 34 | static void GetAll(); 35 | 36 | private: 37 | 38 | static int OpenDevice(const char* dev_name); 39 | 40 | static void ShowInfo(int fd); 41 | 42 | }; 43 | 44 | } 45 | } 46 | } 47 | 48 | #endif // WIZTK_DEVICE_VIDEO_CAMERA_HPP_ 49 | -------------------------------------------------------------------------------- /include/wiztk/graphics/alignment.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #ifndef WIZTK_GRAPHIC_ALIGNMENT_HPP_ 18 | #define WIZTK_GRAPHIC_ALIGNMENT_HPP_ 19 | 20 | #include "wiztk/base/macros.hpp" 21 | 22 | namespace wiztk { 23 | namespace graphics { 24 | 25 | /** 26 | * @ingroup graphics 27 | * @brief Text Alignment 28 | * 29 | * Text alignment adjusts the text relative to the text position. 30 | */ 31 | class WIZTK_EXPORT Alignment { 32 | 33 | public: 34 | 35 | enum Type { 36 | kLeft, 37 | kTop, 38 | kRight, 39 | kBottom 40 | }; 41 | 42 | explicit Alignment(int init = 0) 43 | : value_(init) {} 44 | 45 | int value() const { return value_; } 46 | 47 | private: 48 | 49 | int value_ = 0; 50 | 51 | }; 52 | 53 | } // namespace graphics 54 | } // namespace wiztk 55 | 56 | #endif // WIZTK_GRAPHIC_TEXT_ALIGNMENT_HPP_ 57 | -------------------------------------------------------------------------------- /include/wiztk/graphics/clip-operation.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Freeman Zhang 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 | #ifndef WIZTK_GRAPHIC_CLIP_OPERATION_HPP_ 18 | #define WIZTK_GRAPHIC_CLIP_OPERATION_HPP_ 19 | 20 | namespace wiztk { 21 | namespace graphics { 22 | 23 | /** 24 | * @ingroup graphics 25 | * @brief Clip operations 26 | */ 27 | enum ClipOperation { 28 | kClipDifference, // 0 29 | kClipIntersect, // 1 30 | kClipUnion, 31 | kClipXOR, 32 | 33 | }; 34 | 35 | } // namespace graphics 36 | } // namespace wiztk 37 | 38 | #endif // WIZTK_GRAPHIC_CLIP_OPERATION_HPP_ 39 | -------------------------------------------------------------------------------- /include/wiztk/graphics/matrix.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #ifndef WIZTK_GRAPHICS_MATRIX_HPP_ 18 | #define WIZTK_GRAPHICS_MATRIX_HPP_ 19 | 20 | #include 21 | 22 | namespace wiztk { 23 | namespace graphics { 24 | 25 | /** 26 | * @ingroup graphics 27 | * @brief Skia matrix wrapper 28 | */ 29 | class Matrix { 30 | 31 | public: 32 | 33 | struct Private; 34 | 35 | Matrix(); 36 | 37 | Matrix(const Matrix &other); 38 | 39 | ~Matrix(); 40 | 41 | Matrix &operator=(const Matrix &other); 42 | 43 | private: 44 | 45 | std::unique_ptr p_; 46 | 47 | }; 48 | 49 | } // namespace graphics 50 | } // namespace wiztk 51 | 52 | #endif // WIZTK_GRAPHIC_MATRIX_HPP_ 53 | -------------------------------------------------------------------------------- /include/wiztk/graphics/text-alignment.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #ifndef WIZTK_GRAPHICS_TEXT_ALIGNMENT_HPP_ 18 | #define WIZTK_GRAPHICS_TEXT_ALIGNMENT_HPP_ 19 | 20 | #include "wiztk/base/macros.hpp" 21 | 22 | namespace wiztk { 23 | namespace graphics { 24 | 25 | class WIZTK_EXPORT TextAlignment { 26 | 27 | public: 28 | 29 | enum Horizontal { 30 | kLeft, 31 | kCenter, 32 | kRight 33 | }; 34 | 35 | static constexpr int kHorizontalMask = 0x0F; 36 | 37 | enum Vertical { 38 | kTop = 0x0, 39 | kMiddle = (0x1 << 4), 40 | kBottom = (0x2 << 4), 41 | kBaseline = (0x3 << 4) 42 | }; 43 | 44 | static constexpr int kVerticalMask = 0xF0; 45 | 46 | }; 47 | 48 | } // namespace graphics 49 | } // namespace wiztk 50 | 51 | #endif // WIZTK_GRAPHICS_TEXT_ALIGNMENT_HPP_ 52 | -------------------------------------------------------------------------------- /include/wiztk/gui/abstract-epoll-task.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #ifndef WIZTK_GUI_ABSTRACT_EPOLL_TASK_HPP_ 18 | #define WIZTK_GUI_ABSTRACT_EPOLL_TASK_HPP_ 19 | 20 | namespace wiztk { 21 | namespace gui { 22 | 23 | class AbstractEpollTask { 24 | 25 | public: 26 | 27 | AbstractEpollTask() {} 28 | 29 | virtual ~AbstractEpollTask() {} 30 | 31 | virtual void Run(uint32_t events) = 0; 32 | 33 | }; 34 | 35 | } // namespace gui 36 | } // namespace wiztk 37 | 38 | #endif // WIZTK_GUI_ABSTRACT_EPOLL_TASK_HPP_ 39 | -------------------------------------------------------------------------------- /include/wiztk/gui/gles2-backend.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #ifndef WIZTK_GUI_GLES2_BACKEND_HPP_ 18 | #define WIZTK_GUI_GLES2_BACKEND_HPP_ 19 | 20 | #include "wiztk/gui/abstract-egl-backend.hpp" 21 | 22 | #include 23 | 24 | namespace wiztk { 25 | namespace gui { 26 | 27 | /** 28 | * @ingroup gui 29 | * @brief OpenGL ES V2 Backend. 30 | */ 31 | class WIZTK_EXPORT GLES2Backend : public AbstractEGLBackend { 32 | 33 | public: 34 | 35 | GLES2Backend(); 36 | 37 | ~GLES2Backend() override; 38 | 39 | private: 40 | 41 | struct Private; 42 | 43 | std::unique_ptr p_; 44 | 45 | }; 46 | 47 | } // namespace gui 48 | } // namespace wiztk 49 | 50 | #endif // WIZTK_GUI_GLES2_BACKEND_HPP_ 51 | -------------------------------------------------------------------------------- /include/wiztk/gui/main-window.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #ifndef WIZTK_GUI_MAIN_WINDOW_HPP_ 18 | #define WIZTK_GUI_MAIN_WINDOW_HPP_ 19 | 20 | #include "abstract-shell-view.hpp" 21 | #include "shared-memory-pool.hpp" 22 | #include "buffer.hpp" 23 | 24 | namespace wiztk { 25 | 26 | class AbstractWidget; 27 | 28 | } 29 | 30 | #endif // WIZTK_GUI_MAIN_WINDOW_HPP_ 31 | -------------------------------------------------------------------------------- /include/wiztk/gui/queued-task.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #ifndef WIZTK_GUI_QUEUED_TASK_HPP_ 18 | #define WIZTK_GUI_QUEUED_TASK_HPP_ 19 | 20 | #include "wiztk/base/deque.hpp" 21 | 22 | namespace wiztk { 23 | namespace gui { 24 | 25 | /** 26 | * @ingroup gui 27 | * @brief Task node which is runnable. 28 | */ 29 | class WIZTK_EXPORT QueuedTask : public base::DequeNode { 30 | 31 | public: 32 | 33 | WIZTK_DECLARE_NONCOPYABLE_AND_NONMOVALE(QueuedTask); 34 | 35 | QueuedTask() = default; 36 | 37 | ~QueuedTask() override = default; 38 | 39 | virtual void Run() { 40 | // override this 41 | } 42 | 43 | }; 44 | 45 | } // namespace gui 46 | } // namespace wiztk 47 | 48 | #endif // WIZTK_GUI_TASK_NODE_HPP_ 49 | -------------------------------------------------------------------------------- /include/wiztk/gui/tooltip.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #ifndef WIZTK_GUI_TOOLTIP_HPP_ 18 | #define WIZTK_GUI_TOOLTIP_HPP_ 19 | 20 | #include "abstract-shell-view.hpp" 21 | 22 | namespace wiztk { 23 | namespace gui { 24 | 25 | class PopupShellSurface; 26 | 27 | class Tooltip : public AbstractShellView { 28 | 29 | public: 30 | 31 | Tooltip(AbstractView *view); 32 | 33 | virtual ~Tooltip(); 34 | 35 | private: 36 | 37 | std::string text_; 38 | 39 | }; 40 | 41 | } // namespace gui 42 | } // namespace wiztk 43 | 44 | #endif // WIZTK_GUI_TOOLTIP_HPP_ 45 | -------------------------------------------------------------------------------- /include/wiztk/gui/touch-event.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #ifndef WIZTK_GUI_TOUCH_EVENT_HPP_ 18 | #define WIZTK_GUI_TOUCH_EVENT_HPP_ 19 | 20 | #include "input-event.hpp" 21 | 22 | namespace wiztk { 23 | namespace gui { 24 | 25 | class TouchEvent : public InputEvent { 26 | 27 | friend class Input; 28 | 29 | TouchEvent() = delete; 30 | TouchEvent(const TouchEvent &) = delete; 31 | TouchEvent &operator=(const TouchEvent &) = delete; 32 | 33 | public: 34 | 35 | inline TouchEvent(Input *input) 36 | : InputEvent(input) { 37 | } 38 | 39 | private: 40 | 41 | ~TouchEvent() {} 42 | 43 | }; 44 | 45 | } // namespace gui 46 | } // namespace wiztk 47 | 48 | #endif // WIZTK_GUI_TOUCH_EVENT_HPP_ 49 | -------------------------------------------------------------------------------- /include/wiztk/gui/vulkan-api.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Freeman Zhang 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 | #ifndef WIZTK_GUI_VULKAN_API_HPP_ 18 | #define WIZTK_GUI_VULKAN_API_HPP_ 19 | 20 | #include "abstract-rendering-api.hpp" 21 | 22 | #include 23 | 24 | namespace wiztk { 25 | namespace gui { 26 | 27 | class Surface; 28 | 29 | /** 30 | * @ingroup gui 31 | * @brief Vulkan 32 | */ 33 | class VulkanAPI : public AbstractRenderingAPI { 34 | 35 | public: 36 | 37 | VulkanAPI(); 38 | 39 | virtual ~VulkanAPI(); 40 | 41 | protected: 42 | 43 | virtual void OnSetup() final; 44 | 45 | private: 46 | 47 | vk::SurfaceKHR vk_surface_; 48 | 49 | }; 50 | 51 | } // namespace gui 52 | } // namespace wiztk 53 | 54 | #endif // WIZTK_GUI_VULKAN_API_HPP_ 55 | -------------------------------------------------------------------------------- /include/wiztk/net/protocol-type.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WizTK Authors. 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 | #ifndef WIZTK_NET_PROTOCOL_TYPE_HPP_ 18 | #define WIZTK_NET_PROTOCOL_TYPE_HPP_ 19 | 20 | namespace wiztk { 21 | namespace net { 22 | 23 | /** 24 | * @ingroup net 25 | * @brief Protocol type 26 | */ 27 | enum ProtocolType { 28 | kProtocolDefault = 0 29 | // TODO: more protocol type 30 | }; 31 | 32 | } // namespace net 33 | } // namespace wiztk 34 | 35 | #endif // WIZTK_NET_PROTOCOL_TYPE_HPP_ 36 | -------------------------------------------------------------------------------- /include/wiztk/net/socket-exception.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WizTK Authors. 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 | #ifndef WIZTK_NET_SOCKET_EXCEPTION_HPP_ 18 | #define WIZTK_NET_SOCKET_EXCEPTION_HPP_ 19 | 20 | #include "wiztk/base/exception.hpp" 21 | 22 | namespace wiztk { 23 | namespace net { 24 | 25 | /** 26 | * @ingroup net 27 | */ 28 | class SocketException : public base::Exception { 29 | public: 30 | using base::Exception::Exception; 31 | }; 32 | 33 | } 34 | } 35 | 36 | #endif // WIZTK_NET_SOCKET_EXCEPTION_HPP_ 37 | -------------------------------------------------------------------------------- /include/wiztk/system/logging/logger.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #ifndef WIZTK_SYSTEM_LOGGING_LOGGER_HPP_ 18 | #define WIZTK_SYSTEM_LOGGING_LOGGER_HPP_ 19 | 20 | namespace wiztk { 21 | namespace system { 22 | namespace logging { 23 | 24 | /** 25 | * @ingroup system_logging 26 | * @brief Logger object. 27 | */ 28 | class Logger { 29 | 30 | public: 31 | 32 | Logger() = default; 33 | 34 | ~Logger() = default; 35 | 36 | /** 37 | * @brief Send a message to the system log daemon. 38 | * @param level 39 | * @param format 40 | * @param ... 41 | */ 42 | static void LogToSystem(int level, const char *format, ...); 43 | 44 | private: 45 | 46 | }; 47 | 48 | } 49 | } 50 | } 51 | 52 | #endif // WIZTK_SYSTEM_LOGGING_LOGGER_HPP_ 53 | -------------------------------------------------------------------------------- /include/wiztk/system/logging/type.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #ifndef WIZTK_SYSTEM_LOGGING_TYPE_HPP_ 18 | #define WIZTK_SYSTEM_LOGGING_TYPE_HPP_ 19 | 20 | #include 21 | 22 | namespace wiztk { 23 | namespace system { 24 | namespace logging { 25 | 26 | /** 27 | * @ingroup system_logging 28 | * @brief Log level. 29 | */ 30 | enum Level { 31 | 32 | kDebug = LOG_DEBUG, 33 | 34 | kInfo = LOG_INFO, 35 | 36 | kNotice = LOG_NOTICE, 37 | 38 | kWarning = LOG_WARNING, 39 | 40 | kError = LOG_ERR, 41 | 42 | kCritical = LOG_CRIT, 43 | 44 | kAlert = LOG_ALERT, 45 | 46 | kEmergency = LOG_EMERG 47 | 48 | }; 49 | 50 | } 51 | } 52 | } 53 | 54 | #endif // WIZTK_SYSTEM_LOGGING_TYPE_HPP_ 55 | -------------------------------------------------------------------------------- /include/wiztk/system/time/realtime-clock.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WizTK Authors. 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 | #ifndef WIZTK_SYSTEM_TIME_REALTIME_CLOCK_HPP_ 18 | #define WIZTK_SYSTEM_TIME_REALTIME_CLOCK_HPP_ 19 | 20 | #include "wiztk/system/time/clock.hpp" 21 | 22 | namespace wiztk { 23 | namespace system { 24 | namespace time { 25 | 26 | /** 27 | * @ingroup system_time 28 | * @brief System-wide clock that measures real (i.e., wall-clock) time. 29 | */ 30 | class WIZTK_EXPORT RealtimeClock : public Clock { 31 | 32 | public: 33 | 34 | using Clock::Clock; 35 | 36 | ~RealtimeClock() final = default; 37 | 38 | static RealtimeClock Now(Precision precision = kMilliseconds); 39 | 40 | }; 41 | 42 | } // namespace time 43 | } // namespace system 44 | } // namespace wiztk 45 | 46 | #endif // WIZTK_SYSTEM_TIME_REALTIME_CLOCK_HPP_ 47 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Freeman Zhang 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | add_subdirectory(wiztk) 16 | -------------------------------------------------------------------------------- /src/wiztk/async/event-loop/private.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #include "private.hpp" 18 | 19 | namespace wiztk { 20 | namespace async { 21 | 22 | system::threading::ThreadLocal EventLoop::Private::kPerThreadStorage; 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/wiztk/async/event-loop/private.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #ifndef WIZTK_ASYNC_EVENT_LOOP_PRIVATE_HPP_ 18 | #define WIZTK_ASYNC_EVENT_LOOP_PRIVATE_HPP_ 19 | 20 | #include "wiztk/async/event-loop.hpp" 21 | 22 | #include "wiztk/system/threading/thread-local.hpp" 23 | 24 | namespace wiztk { 25 | namespace async { 26 | 27 | /** 28 | * @brief Private structure in EventLoop. 29 | */ 30 | struct EventLoop::Private { 31 | 32 | /** 33 | * @brief A static object stores EventLoop in each thread. 34 | */ 35 | static system::threading::ThreadLocal kPerThreadStorage; 36 | 37 | }; 38 | 39 | } 40 | } 41 | 42 | #endif // WIZTK_ASYNC_EVENT_LOOP_PRIVATE_HPP_ 43 | -------------------------------------------------------------------------------- /src/wiztk/async/message-queue.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #include "wiztk/async/message-queue.hpp" 18 | 19 | namespace wiztk { 20 | namespace async { 21 | 22 | MessageQueue::MessageQueue() 23 | : traits_(this) { 24 | } 25 | 26 | void MessageQueue::PushFront(Message *message) { 27 | traits_.push_front(&message->traits_); 28 | } 29 | 30 | void MessageQueue::PushBack(Message *message) { 31 | traits_.push_back(&message->traits_); 32 | } 33 | 34 | Message *MessageQueue::PopFront() { 35 | if (traits_.is_empty()) return nullptr; 36 | 37 | auto it = traits_.begin(); 38 | it->unlink(); 39 | return it->message(); 40 | } 41 | 42 | Message *MessageQueue::PopBack() { 43 | if (traits_.is_empty()) return nullptr; 44 | 45 | auto it = traits_.rbegin(); 46 | it->unlink(); 47 | return it->message(); 48 | } 49 | 50 | } 51 | } -------------------------------------------------------------------------------- /src/wiztk/device/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2017 - 2018 The WizTK Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | set( 16 | device_sources 17 | ${PROJECT_SOURCE_DIR}/include/wiztk/device/video/camera.hpp 18 | video/camera.cpp 19 | ) 20 | 21 | if (BUILD_SHARED_LIBRARY) 22 | add_library(wiztk-device SHARED ${config_header} ${device_sources}) 23 | set_target_properties(wiztk-device PROPERTIES VERSION 1 SOVERSION 1) 24 | else () 25 | add_library(wiztk-device ${config_header} ${device_sources}) 26 | endif () 27 | 28 | #target_link_libraries( 29 | # wiztk-base 30 | # PUBLIC rt 31 | # PUBLIC ${LIBS} 32 | # PUBLIC wayland-cursor 33 | # PRIVATE skia 34 | # PRIVATE xdg-shell-unstable-v6 35 | # # PRIVATE icu_utf # in third_party 36 | #) 37 | 38 | install(TARGETS wiztk-device DESTINATION lib) 39 | -------------------------------------------------------------------------------- /src/wiztk/graphics/canvas/native.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #ifndef WIZTK_FRAMEWORK_NATIVE_HPP 18 | #define WIZTK_FRAMEWORK_NATIVE_HPP 19 | 20 | #include "private.hpp" 21 | 22 | namespace wiztk { 23 | namespace graphics { 24 | 25 | class Canvas::Native { 26 | 27 | public: 28 | 29 | static inline SkCanvas* sk_canvas(const Canvas* canvas) { 30 | return &canvas->p_->sk_canvas; 31 | } 32 | 33 | }; 34 | 35 | } // graphics 36 | } // wiztk 37 | 38 | #endif //WIZTK_FRAMEWORK_NATIVE_HPP 39 | -------------------------------------------------------------------------------- /src/wiztk/graphics/matrix.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #include "matrix/private.hpp" 18 | 19 | namespace wiztk { 20 | namespace graphics { 21 | 22 | Matrix::Matrix() { 23 | p_ = std::make_unique(); 24 | } 25 | 26 | Matrix::Matrix(const Matrix &other) { 27 | p_ = std::make_unique(*other.p_); 28 | } 29 | 30 | Matrix::~Matrix() = default; 31 | 32 | Matrix &Matrix::operator=(const Matrix &other) { 33 | *p_ = *other.p_; 34 | return *this; 35 | } 36 | 37 | } // namespace graphics 38 | } // namespace wiztk 39 | -------------------------------------------------------------------------------- /src/wiztk/graphics/matrix/private.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #ifndef WIZTK_MATRIX_PRIVATE_HPP 18 | #define WIZTK_MATRIX_PRIVATE_HPP 19 | 20 | #include "wiztk/graphics/matrix.hpp" 21 | 22 | #include "SkMatrix.h" 23 | 24 | namespace wiztk { 25 | namespace graphics { 26 | 27 | struct Matrix::Private { 28 | 29 | static const Private &Get(const Matrix &matrix) { 30 | return *matrix.p_; 31 | } 32 | 33 | Private() = default; 34 | 35 | Private(const Private &orig) = default; 36 | 37 | ~Private() = default; 38 | 39 | SkMatrix sk_matrix; 40 | 41 | }; 42 | 43 | } // namespace graphics 44 | } // namespace wiztk 45 | 46 | #endif //WIZTK_MATRIX_PRIVATE_HPP 47 | -------------------------------------------------------------------------------- /src/wiztk/graphics/paint/private.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #ifndef WIZTK_GRAPHICS_PAINT_PRIVATE_HPP_ 18 | #define WIZTK_GRAPHICS_PAINT_PRIVATE_HPP_ 19 | 20 | #include "wiztk/graphics/paint.hpp" 21 | 22 | #include "SkPaint.h" 23 | #include "SkTypeface.h" 24 | 25 | namespace wiztk { 26 | namespace graphics { 27 | 28 | struct Paint::Private { 29 | 30 | static const Private &Get(const Paint &paint) { 31 | return *paint.p_; 32 | } 33 | 34 | Private() = default; 35 | 36 | Private(const Private &) = default; 37 | 38 | ~Private() = default; 39 | 40 | Private &operator=(const Private &) = default; 41 | 42 | SkPaint sk_paint; 43 | 44 | }; 45 | 46 | } // namespace graphics 47 | } // namespace wiztk 48 | 49 | #endif // WIZTK_GRAPHICS_PAINT_PRIVATE_HPP_ 50 | -------------------------------------------------------------------------------- /src/wiztk/graphics/path/private.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #ifndef WIZTK_GRAPHICS_PATH_PRIVATE_HPP_ 18 | #define WIZTK_GRAPHICS_PATH_PRIVATE_HPP_ 19 | 20 | #include "wiztk/graphics/path.hpp" 21 | 22 | #include "SkPath.h" 23 | 24 | namespace wiztk { 25 | namespace graphics { 26 | 27 | using base::Point2F; 28 | using base::RectF; 29 | 30 | struct Path::Private { 31 | 32 | static const Private &Get(const Path &path) { 33 | return *path.p_; 34 | } 35 | 36 | Private() = default; 37 | 38 | Private(const Private &orig) = default; 39 | 40 | ~Private() = default; 41 | 42 | Private &operator=(const Private &) = default; 43 | 44 | SkPath sk_path; 45 | 46 | }; 47 | 48 | } 49 | } 50 | 51 | #endif // WIZTK_GRAPHICS_PATH_PRIVATE_HPP_ 52 | -------------------------------------------------------------------------------- /src/wiztk/graphics/shader.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #include "shader/private.hpp" 18 | 19 | #include "wiztk/base/macros.hpp" 20 | 21 | namespace wiztk { 22 | namespace graphics { 23 | 24 | Shader::Shader() { 25 | p_ = std::make_unique(); 26 | } 27 | 28 | Shader::Shader(Private *p) 29 | : p_(p) { 30 | _ASSERT(p_); 31 | } 32 | 33 | Shader::Shader(const Shader &other) { 34 | p_ = std::make_unique(other.p_->sk_shader_sp); 35 | } 36 | 37 | Shader::~Shader() = default; 38 | 39 | Shader &Shader::operator=(const Shader &other) { 40 | *p_ = *other.p_; 41 | return *this; 42 | } 43 | 44 | Shader::operator bool() const { 45 | return p_->sk_shader_sp.get() != nullptr; 46 | } 47 | 48 | } // namespace graphics 49 | } // namespace wiztk 50 | -------------------------------------------------------------------------------- /src/wiztk/graphics/surface-props.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Freeman Zhang 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 | #include "surface-props/private.hpp" 18 | 19 | #include "canvas/private.hpp" 20 | #include "image-info/private.hpp" 21 | 22 | namespace wiztk { 23 | namespace graphics { 24 | 25 | SurfaceProps::SurfaceProps() { 26 | p_ = std::make_unique(); 27 | } 28 | 29 | SurfaceProps::SurfaceProps(uint32_t flags) { 30 | p_ = std::make_unique(flags); 31 | } 32 | 33 | SurfaceProps::SurfaceProps(SurfaceProps &&other) noexcept { 34 | p_ = std::move(other.p_); 35 | } 36 | 37 | SurfaceProps &SurfaceProps::operator=(SurfaceProps &&other) noexcept { 38 | p_ = std::move(other.p_); 39 | return *this; 40 | } 41 | 42 | SurfaceProps::~SurfaceProps() = default; 43 | 44 | } // namespace graphics 45 | } // namespace wiztk 46 | -------------------------------------------------------------------------------- /src/wiztk/graphics/surface-props/private.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #ifndef WIZTK_GRAPHICS_SURFACE_PROPERTIES_PRIVATE_HPP_ 18 | #define WIZTK_GRAPHICS_SURFACE_PROPERTIES_PRIVATE_HPP_ 19 | 20 | #include "wiztk/graphics/surface-props.hpp" 21 | 22 | #include "SkSurfaceProps.h" 23 | 24 | namespace wiztk { 25 | namespace graphics { 26 | 27 | struct SurfaceProps::Private { 28 | 29 | static const Private &Get(const SurfaceProps &props) { 30 | return *props.p_; 31 | } 32 | 33 | Private() 34 | : sk_surface_props(SkSurfaceProps::kLegacyFontHost_InitType) { 35 | } 36 | 37 | explicit Private(uint32_t flags) 38 | : sk_surface_props(flags, SkSurfaceProps::kLegacyFontHost_InitType) {} 39 | 40 | SkSurfaceProps sk_surface_props; 41 | 42 | }; 43 | 44 | } 45 | } 46 | 47 | #endif // WIZTK_GRAPHICS_SURFACE_PROPERTIES_PRIVATE_HPP_ 48 | -------------------------------------------------------------------------------- /src/wiztk/gui/abstract-rendering-api_private.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Freeman Zhang 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 | #ifndef WIZTK_GUI_INTERNAL_ABSTRACT_RENDERING_API_PRIVATE_HPP_ 18 | #define WIZTK_GUI_INTERNAL_ABSTRACT_RENDERING_API_PRIVATE_HPP_ 19 | 20 | #include "wiztk/gui/abstract-rendering-api.hpp" 21 | 22 | #include "surface/private.hpp" 23 | 24 | namespace wiztk { 25 | namespace gui { 26 | 27 | /** 28 | * @brief Structure for private data in AbstractGPUInterface 29 | */ 30 | struct AbstractRenderingAPI::Private { 31 | 32 | WIZTK_DECLARE_NONCOPYABLE_AND_NONMOVALE(Private); 33 | 34 | Private() = default; 35 | 36 | ~Private() = default; 37 | 38 | Surface *surface = nullptr; 39 | 40 | }; 41 | 42 | } // namespace gui 43 | } // namespace wiztk 44 | 45 | #endif // WIZTK_GUI_INTERNAL_ABSTRACT_GR_API_PRIVATE_HPP_ 46 | -------------------------------------------------------------------------------- /src/wiztk/gui/abstract-rendering-api_proxy.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Freeman Zhang 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 | #ifndef WIZTK_GUI_INTERNAL_ABSTRACT_RENDERING_API_PROXY_HPP_ 18 | #define WIZTK_GUI_INTERNAL_ABSTRACT_RENDERING_API_PROXY_HPP_ 19 | 20 | #include "wiztk/gui/abstract-rendering-api.hpp" 21 | 22 | #include "surface/private.hpp" 23 | 24 | namespace wiztk { 25 | namespace gui { 26 | 27 | struct AbstractRenderingAPI::Proxy { 28 | 29 | static inline struct wl_surface *GetWaylandSurface(const Surface *surface) { 30 | return surface->p_->wl_surface; 31 | } 32 | 33 | }; 34 | 35 | } // namespace gui 36 | } // namespace wiztk 37 | 38 | #endif // WIZTK_GUI_INTERNAL_ABSTRACT_GR_API_PROXY_HPP_ 39 | -------------------------------------------------------------------------------- /src/wiztk/gui/abstract-rendering-backend.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #include "wiztk/gui/abstract-rendering-backend.hpp" 18 | 19 | namespace wiztk { 20 | namespace gui { 21 | 22 | AbstractRenderingBackend::AbstractRenderingBackend() = default; 23 | 24 | AbstractRenderingBackend::~AbstractRenderingBackend() = default; 25 | 26 | void AbstractRenderingBackend::Setup(AbstractSurface *surface) { 27 | OnSetup(surface); 28 | } 29 | 30 | void AbstractRenderingBackend::Release(AbstractSurface *surface) { 31 | OnRelease(surface); 32 | } 33 | 34 | } // namespace graphics 35 | } // namespace wiztk 36 | -------------------------------------------------------------------------------- /src/wiztk/gui/buffer/private.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Freeman Zhang 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 | #include "private.hpp" 18 | 19 | namespace wiztk { 20 | namespace gui { 21 | 22 | const struct wl_buffer_listener Buffer::Private::kListener = { 23 | OnRelease 24 | }; 25 | 26 | void Buffer::Private::OnRelease(void *data, struct wl_buffer */*buffer*/) { 27 | auto *_this = static_cast(data); 28 | _this->release_.Emit(); 29 | } 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/wiztk/gui/gles2-backend/private.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #include "private.hpp" 18 | 19 | #include "display/private.hpp" 20 | 21 | #include "wiztk/gui/application.hpp" 22 | 23 | namespace wiztk { 24 | namespace gui { 25 | 26 | } 27 | } -------------------------------------------------------------------------------- /src/wiztk/gui/gles2-backend/private.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #ifndef WIZTK_FRAMEWORK_GLES2_BACKEND_PRIVATE_HPP 18 | #define WIZTK_FRAMEWORK_GLES2_BACKEND_PRIVATE_HPP 19 | 20 | #include "wiztk/gui/gles2-backend.hpp" 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace wiztk { 27 | namespace gui { 28 | 29 | /** 30 | * @brief Private data in GLES2Backend. 31 | */ 32 | struct GLES2Backend::Private { 33 | 34 | EGLContext egl_context = nullptr; 35 | 36 | EGLSurface egl_surface = nullptr; 37 | 38 | struct wl_egl_window *wl_egl_window = nullptr; 39 | 40 | }; 41 | 42 | } 43 | } 44 | 45 | #endif //WIZTK_FRAMEWORK_GLES2_BACKEND_PRIVATE_HPP 46 | -------------------------------------------------------------------------------- /src/wiztk/gui/input-event.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #include 18 | 19 | #include 20 | 21 | namespace wiztk { 22 | namespace gui { 23 | 24 | void InputEvent::SetCursor(const Cursor *cursor) const { 25 | input_->SetCursor(cursor); 26 | } 27 | 28 | } // namespace gui 29 | } // namespace wiztk 30 | -------------------------------------------------------------------------------- /src/wiztk/gui/input-manager.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #include "input/private.hpp" 18 | 19 | #include "wiztk/gui/input-manager.hpp" 20 | 21 | namespace wiztk { 22 | namespace gui { 23 | 24 | InputManager::~InputManager() { 25 | Clear(); 26 | } 27 | 28 | void InputManager::AddInput(Input *input) { 29 | auto *node = input->p_.get(); 30 | deque_.push_back(node); 31 | } 32 | 33 | void InputManager::Clear() { 34 | deque_.clear([](base::CountedDequeNodeBase *obj) { 35 | auto *node = static_cast(obj); 36 | Input *input = node->proprietor; 37 | delete input; 38 | }); 39 | } 40 | 41 | } 42 | } -------------------------------------------------------------------------------- /src/wiztk/gui/keyboard_state.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Freeman Zhang 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 | #include 18 | #include "keyboard_state.hpp" 19 | #include "keymap.hpp" 20 | 21 | namespace wiztk { 22 | namespace gui { 23 | 24 | KeyboardState::~KeyboardState() { 25 | if (xkb_state_) xkb_state_unref(xkb_state_); 26 | } 27 | 28 | void KeyboardState::Setup(const Keymap &keymap) { 29 | Destroy(); 30 | 31 | xkb_state_ = xkb_state_new(keymap.xkb_keymap_); 32 | if (nullptr == xkb_state_) { 33 | xkb_keymap_unref(keymap.xkb_keymap_); 34 | throw std::runtime_error("FATAL! Cannot create keyboard state!"); 35 | } 36 | } 37 | 38 | void KeyboardState::Destroy() { 39 | if (xkb_state_) { 40 | xkb_state_unref(xkb_state_); 41 | xkb_state_ = nullptr; 42 | } 43 | } 44 | 45 | } // namespace gui 46 | } // namespace wiztk 47 | -------------------------------------------------------------------------------- /src/wiztk/gui/keyboard_state.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Freeman Zhang 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 | #ifndef WIZTK_GUI_INTERNAL_KEYBOARD_STATE_HPP_ 18 | #define WIZTK_GUI_INTERNAL_KEYBOARD_STATE_HPP_ 19 | 20 | #include 21 | 22 | namespace wiztk { 23 | namespace gui { 24 | 25 | class Keymap; 26 | 27 | class KeyboardState { 28 | 29 | public: 30 | 31 | KeyboardState() 32 | : xkb_state_(nullptr) {} 33 | 34 | ~KeyboardState(); 35 | 36 | void Setup(const Keymap &keymap); 37 | 38 | void Destroy(); 39 | 40 | private: 41 | 42 | struct xkb_state *xkb_state_; 43 | 44 | }; 45 | 46 | } // namespace gui 47 | } // namespace wiztk 48 | 49 | #endif // WIZTK_GUI_INTERNAL_KEYBOARD_STATE_HPP_ 50 | -------------------------------------------------------------------------------- /src/wiztk/gui/linear-layout.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Freeman Zhang 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 | #include "abstract-view/iterators.hpp" 18 | 19 | #include 20 | 21 | namespace wiztk { 22 | namespace gui { 23 | 24 | LinearLayout::LinearLayout(Orientation orientation, const Padding &padding, int space) 25 | : AbstractLayout(padding) { 26 | 27 | } 28 | 29 | LinearLayout::~LinearLayout() { 30 | 31 | } 32 | 33 | void LinearLayout::OnViewAdded(AbstractView *view) { 34 | // TODO: 35 | } 36 | 37 | void LinearLayout::OnViewRemoved(AbstractView *view) { 38 | // TODO: 39 | } 40 | 41 | void LinearLayout::OnLayout(int left, int top, int right, int bottom) { 42 | 43 | } 44 | 45 | } // namespace gui 46 | } // namespace wiztk 47 | -------------------------------------------------------------------------------- /src/wiztk/gui/main-loop/display-event.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #ifndef WIZTK_GUI_MAIN_LOOP_DISPLAY_EVENT_HPP_ 18 | #define WIZTK_GUI_MAIN_LOOP_DISPLAY_EVENT_HPP_ 19 | 20 | #include "wiztk/gui/main-loop.hpp" 21 | 22 | namespace wiztk { 23 | namespace gui { 24 | 25 | class MainLoop::DisplayEvent : public async::AbstractEvent { 26 | 27 | public: 28 | 29 | explicit DisplayEvent(MainLoop *main_loop); 30 | 31 | ~DisplayEvent() final; 32 | 33 | protected: 34 | 35 | void Run(uint32_t events) final; 36 | 37 | private: 38 | 39 | MainLoop *main_loop_ = nullptr; 40 | 41 | }; 42 | 43 | } // namespace gui 44 | } // namespace wiztk 45 | 46 | #endif // WIZTK_GUI_MAIN_LOOP_DISPLAY_EVENT_HPP_ 47 | -------------------------------------------------------------------------------- /src/wiztk/gui/main-loop/private.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #include "private.hpp" 18 | 19 | namespace wiztk { 20 | namespace gui { 21 | 22 | MainLoop::Private::Private(MainLoop *main_loop) 23 | : signal_event(main_loop), display_event(main_loop) {} 24 | 25 | } 26 | } -------------------------------------------------------------------------------- /src/wiztk/gui/main-loop/private.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #ifndef WIZTK_GUI_MAIN_LOOP_PRIVATE_HPP_ 18 | #define WIZTK_GUI_MAIN_LOOP_PRIVATE_HPP_ 19 | 20 | #include "signal-event.hpp" 21 | #include "display-event.hpp" 22 | 23 | #include "wiztk/gui/main-loop.hpp" 24 | 25 | #include 26 | 27 | namespace wiztk { 28 | namespace gui { 29 | 30 | struct MainLoop::Private { 31 | 32 | explicit Private(MainLoop *main_loop); 33 | 34 | ~Private() = default; 35 | 36 | struct wl_display *wl_display = nullptr; 37 | 38 | SignalEvent signal_event; 39 | 40 | DisplayEvent display_event; 41 | 42 | }; 43 | 44 | } // namespace gui 45 | } // namespace wiztk 46 | 47 | #endif // WIZTK_GUI_MAIN_LOOP_PRIVATE_HPP_ 48 | -------------------------------------------------------------------------------- /src/wiztk/gui/main-loop/signal-event.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #ifndef WIZTK_GUI_MAIN_LOOP_SIGNAL_EVENT_HPP_ 18 | #define WIZTK_GUI_MAIN_LOOP_SIGNAL_EVENT_HPP_ 19 | 20 | #include "wiztk/gui/main-loop.hpp" 21 | 22 | namespace wiztk { 23 | namespace gui { 24 | 25 | class MainLoop::SignalEvent : public async::AbstractEvent { 26 | 27 | friend class MainLoop; 28 | 29 | public: 30 | 31 | explicit SignalEvent(MainLoop *main_loop); 32 | 33 | ~SignalEvent() final; 34 | 35 | protected: 36 | 37 | void Run(uint32_t events) final; 38 | 39 | private: 40 | 41 | int signal_fd_ = -1; 42 | 43 | MainLoop *main_loop_ = nullptr; 44 | 45 | }; 46 | 47 | } 48 | } 49 | 50 | #endif // WIZTK_GUI_MAIN_LOOP_SIGNAL_EVENT_HPP_ 51 | -------------------------------------------------------------------------------- /src/wiztk/gui/main-window.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Freeman Zhang 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 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | 26 | namespace wiztk { 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/wiztk/gui/region.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #include "display/private.hpp" 18 | 19 | #include "wiztk/gui/region.hpp" 20 | #include "wiztk/gui/application.hpp" 21 | 22 | namespace wiztk { 23 | namespace gui { 24 | 25 | Region::Region() 26 | : wl_region_(nullptr) { 27 | Display *display = Application::GetInstance()->GetDisplay(); 28 | wl_region_ = wl_compositor_create_region(Display::Private::Get(*display).wl_compositor); 29 | } 30 | 31 | Region::~Region() { 32 | if (wl_region_) 33 | wl_region_destroy(wl_region_); 34 | } 35 | 36 | } // namespace gui 37 | } // namespace wiztk 38 | -------------------------------------------------------------------------------- /src/wiztk/gui/surface/shell/private.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #include "private.hpp" 18 | 19 | #include "surface/private.hpp" 20 | #include "abstract-shell-view/private.hpp" 21 | 22 | namespace wiztk { 23 | namespace gui { 24 | 25 | const struct zxdg_surface_v6_listener Surface::Shell::Private::kListener = { 26 | OnConfigure 27 | }; 28 | 29 | void Surface::Shell::Private::OnConfigure(void *data, 30 | struct zxdg_surface_v6 *zxdg_surface_v6, 31 | uint32_t serial) { 32 | auto *_this = static_cast(data); 33 | auto *shell_view = dynamic_cast(_this->surface_->p_->event_handler); 34 | if (shell_view) 35 | shell_view->p_->OnXdgSurfaceConfigure(serial); 36 | } 37 | 38 | } // namespace gui 39 | } // namespace wiztk 40 | -------------------------------------------------------------------------------- /src/wiztk/gui/theme-dark.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #ifndef WIZTK_STOCK_INTERNAL_THEME_DARK_HPP_ 18 | #define WIZTK_STOCK_INTERNAL_THEME_DARK_HPP_ 19 | 20 | extern "C" { 21 | 22 | void *ThemeDarkCreate(); 23 | void ThemeDarkDestroy(void *p); 24 | 25 | } 26 | 27 | #endif // WIZTK_STOCK_INTERNAL_THEME_DARK_HPP_ 28 | -------------------------------------------------------------------------------- /src/wiztk/gui/theme-light.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #ifndef WIZTK_STOCK_INTERNAL_THEME_LIGHT_HPP_ 18 | #define WIZTK_STOCK_INTERNAL_THEME_LIGHT_HPP_ 19 | 20 | extern "C" { 21 | 22 | void *ThemeLightCreate(); 23 | void ThemeLightDestroy(void *p); 24 | 25 | } 26 | 27 | #endif // WIZTK_STOCK_INTERNAL_THEME_LIGHT_HPP_ 28 | -------------------------------------------------------------------------------- /src/wiztk/gui/tooltip.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #include 18 | 19 | namespace wiztk { 20 | namespace gui { 21 | 22 | Tooltip::Tooltip(AbstractView *view) 23 | : AbstractShellView(nullptr) { 24 | 25 | } 26 | 27 | Tooltip::~Tooltip() { 28 | 29 | } 30 | 31 | } // namespace gui 32 | } // namespace wiztk 33 | -------------------------------------------------------------------------------- /src/wiztk/net/address-info/private.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WizTK Authors. 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 | #ifndef WIZTK_NET_INTERNAL_ADDRESS_INFO_PRIVATE_HPP_ 18 | #define WIZTK_NET_INTERNAL_ADDRESS_INFO_PRIVATE_HPP_ 19 | 20 | #include "wiztk/net/address-info.hpp" 21 | 22 | namespace wiztk { 23 | namespace net { 24 | 25 | using base::CountedDequeNode; 26 | 27 | struct WIZTK_NO_EXPORT AddressInfo::Private : public CountedDequeNode { 28 | 29 | WIZTK_DECLARE_NONCOPYABLE_AND_NONMOVALE(Private); 30 | Private() = delete; 31 | 32 | explicit Private(AddressInfo *addr_info) 33 | : proprietor(addr_info) {} 34 | 35 | AddressInfo *proprietor = nullptr; 36 | 37 | struct addrinfo *address_info = nullptr; 38 | 39 | }; 40 | 41 | } // namespace net 42 | } // namespace wiztk 43 | 44 | #endif // WIZTK_NET_INTERNAL_ADDRESS_INFO_PRIVATE_HPP_ 45 | -------------------------------------------------------------------------------- /src/wiztk/net/io-buffer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WizTK Authors. 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 | #include "wiztk/net/io-buffer.hpp" 18 | 19 | #include 20 | 21 | namespace wiztk { 22 | namespace net { 23 | 24 | IOBuffer::IOBuffer(size_t size) { 25 | data_ = new char[size]; 26 | } 27 | 28 | IOBuffer::~IOBuffer() { 29 | delete[] data_; 30 | } 31 | 32 | void IOBuffer::Reset(size_t size) { 33 | delete[] data_; 34 | data_ = new char[size]; 35 | } 36 | 37 | } 38 | } -------------------------------------------------------------------------------- /src/wiztk/net/ip-address/native.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WizTK Authors. 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 | #include "native.hpp" 18 | 19 | #include "wiztk/base/property.hpp" 20 | 21 | namespace wiztk { 22 | namespace net { 23 | 24 | socklen_t IPAddress::Native::GetSocketLength(const IPAddress &address) { 25 | socklen_t length = 0; 26 | 27 | switch (address.__PROPERTY__(socket_address)->sa_family) { 28 | case AF_INET: { 29 | length = sizeof(struct sockaddr_in); 30 | break; 31 | } 32 | case AF_INET6: { 33 | length = sizeof(struct sockaddr_in6); 34 | break; 35 | } 36 | default:break; 37 | } 38 | 39 | return length; 40 | } 41 | 42 | } // namespace net 43 | } // namespace wiztk 44 | -------------------------------------------------------------------------------- /src/wiztk/net/ip-address/native.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WizTK Authors. 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 | #ifndef WIZTK_NET_INTERNAL_IP_ADDRESS_NATIVE_HPP_ 18 | #define WIZTK_NET_INTERNAL_IP_ADDRESS_NATIVE_HPP_ 19 | 20 | #include "private.hpp" 21 | 22 | namespace wiztk { 23 | namespace net { 24 | 25 | /** 26 | * @brief Proxy class to get native structure in IPAddress. 27 | */ 28 | class WIZTK_NO_EXPORT IPAddress::Native { 29 | 30 | public: 31 | 32 | static socklen_t GetSocketLength(const IPAddress &address); 33 | 34 | static const struct sockaddr *GetSocketAddress(const IPAddress &address) { 35 | return address.p_->socket_address; 36 | } 37 | 38 | }; 39 | 40 | } 41 | } 42 | 43 | #endif // WIZTK_NET_INTERNAL_IP_ADDRESS_NATIVE_HPP_ 44 | -------------------------------------------------------------------------------- /src/wiztk/system/time/delta.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WizTK Authors. 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 | #include "wiztk/system/time/delta.hpp" -------------------------------------------------------------------------------- /src/wiztk/system/time/realtime-clock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WizTK Authors. 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 | #include 18 | #include "wiztk/system/time/realtime-clock.hpp" 19 | 20 | namespace wiztk { 21 | namespace system { 22 | namespace time { 23 | 24 | RealtimeClock RealtimeClock::Now(Precision precision) { 25 | RealtimeClock clock; 26 | 27 | if (clock_gettime(CLOCK_REALTIME, &clock.timespec_)) { 28 | throw std::runtime_error("Error! Fail to get clock time!"); 29 | } 30 | 31 | return clock; 32 | } 33 | 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Freeman Zhang 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | add_subdirectory(wiztk) 16 | 17 | -------------------------------------------------------------------------------- /test/wiztk/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2017 - 2018 The WizTK Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) 16 | 17 | # core module 18 | add_subdirectory(base) 19 | add_subdirectory(system) 20 | add_subdirectory(device) 21 | add_subdirectory(async) 22 | add_subdirectory(graphics) 23 | add_subdirectory(net) 24 | add_subdirectory(gui) 25 | -------------------------------------------------------------------------------- /test/wiztk/async/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(event-loop) 2 | -------------------------------------------------------------------------------- /test/wiztk/async/event-loop/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2017 - 2018 The WizTK Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | file(GLOB sources "*.cpp") 16 | file(GLOB headers "*.hpp") 17 | 18 | add_executable(async-event-loop ${sources} ${headers}) 19 | target_link_libraries(async-event-loop ${GTEST_LIBRARIES} wiztk-async wiztk-system) -------------------------------------------------------------------------------- /test/wiztk/async/event-loop/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, char *argv[]) { 4 | testing::InitGoogleTest(&argc, argv); 5 | return RUN_ALL_TESTS(); 6 | } -------------------------------------------------------------------------------- /test/wiztk/async/event-loop/test-event-loop.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #ifndef WIZTK_TEST_ASYNC_EVENT_LOOP_HPP_ 18 | #define WIZTK_TEST_ASYNC_EVENT_LOOP_HPP_ 19 | 20 | #include 21 | 22 | class TestEventLoop : public testing::Test { 23 | 24 | public: 25 | 26 | TestEventLoop() = default; 27 | 28 | ~TestEventLoop() override = default; 29 | 30 | protected: 31 | 32 | void SetUp() final {} 33 | 34 | void TearDown() final {} 35 | 36 | }; 37 | 38 | #endif // WIZTK_TEST_ASYNC_EVENT_LOOP_HPP_ 39 | -------------------------------------------------------------------------------- /test/wiztk/base/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The WizTK Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) 16 | 17 | # core module 18 | add_subdirectory(delegate) 19 | add_subdirectory(sigcxx) 20 | add_subdirectory(string) 21 | add_subdirectory(margin) 22 | add_subdirectory(rect) 23 | add_subdirectory(color) 24 | add_subdirectory(memory) 25 | add_subdirectory(object) 26 | add_subdirectory(vectors) 27 | add_subdirectory(deque) 28 | add_subdirectory(counted-deque) 29 | add_subdirectory(trace) 30 | #add_subdirectory(async-loop) 31 | -------------------------------------------------------------------------------- /test/wiztk/base/color/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2017 - 2018 The WizTK Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | file(GLOB sources "*.cpp") 16 | file(GLOB headers "*.hpp") 17 | 18 | add_executable(base-color ${sources} ${headers}) 19 | target_link_libraries(base-color ${GTEST_LIBRARIES} wiztk-base) -------------------------------------------------------------------------------- /test/wiztk/base/color/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include 6 | 7 | int main(int argc, char *argv[]) { 8 | testing::InitGoogleTest(&argc, argv); 9 | return RUN_ALL_TESTS(); 10 | } -------------------------------------------------------------------------------- /test/wiztk/base/color/test-color.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #ifndef WIZTK_TEST_BASE_MEMORY_REF_COUNTED_BASE_HPP_ 6 | #define WIZTK_TEST_BASE_MEMORY_REF_COUNTED_BASE_HPP_ 7 | 8 | #include 9 | 10 | class TestColor : public testing::Test { 11 | 12 | public: 13 | 14 | TestColor() = default; 15 | 16 | ~TestColor() override = default; 17 | 18 | protected: 19 | 20 | void SetUp() final {} 21 | 22 | void TearDown() final {} 23 | 24 | }; 25 | 26 | #endif //WAYLAND_TOOLKIT_TEST_HPP 27 | -------------------------------------------------------------------------------- /test/wiztk/base/counted-deque/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2017 - 2018 The WizTK Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | file(GLOB sources "*.cpp") 16 | file(GLOB headers "*.hpp") 17 | 18 | add_executable(base-counted-deque ${sources} ${headers}) 19 | target_link_libraries(base-counted-deque ${GTEST_LIBRARIES} wiztk-base) -------------------------------------------------------------------------------- /test/wiztk/base/counted-deque/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include 6 | 7 | int main(int argc, char *argv[]) { 8 | testing::InitGoogleTest(&argc, argv); 9 | return RUN_ALL_TESTS(); 10 | } -------------------------------------------------------------------------------- /test/wiztk/base/counted-deque/test-counted-deque.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #ifndef SKLAND_TEST_BASE_DEQUE_HPP_ 6 | #define SKLAND_TEST_BASE_DEQUE_HPP_ 7 | 8 | #include 9 | 10 | class TestCountedDeque : public testing::Test { 11 | 12 | public: 13 | 14 | TestCountedDeque() = default; 15 | 16 | ~TestCountedDeque() override = default; 17 | 18 | protected: 19 | 20 | void SetUp() final {} 21 | 22 | void TearDown() final {} 23 | 24 | }; 25 | 26 | #endif // SKLAND_TEST_BASE_COUNTED_DEQUE_HPP_ 27 | -------------------------------------------------------------------------------- /test/wiztk/base/delegate/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2017 - 2018 The WizTK Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | file(GLOB sources "*.cpp") 16 | file(GLOB headers "*.hpp") 17 | 18 | add_executable(base-delegate ${sources} ${headers}) 19 | target_link_libraries(base-delegate ${GTEST_LIBRARIES} wiztk-base) 20 | -------------------------------------------------------------------------------- /test/wiztk/base/delegate/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include 6 | 7 | int main(int argc, char *argv[]) { 8 | testing::InitGoogleTest(&argc, argv); 9 | return RUN_ALL_TESTS(); 10 | } -------------------------------------------------------------------------------- /test/wiztk/base/delegate/test-delegate.hpp: -------------------------------------------------------------------------------- 1 | // 2 | 3 | #ifndef WIZTK_TEST_BASE_DELEGATE_HPP_ 4 | #define WIZTK_TEST_BASE_DELEGATE_HPP_ 5 | 6 | #include 7 | 8 | class TestDelegate : public testing::Test { 9 | 10 | public: 11 | 12 | TestDelegate() = default; 13 | 14 | ~TestDelegate() override = default; 15 | 16 | protected: 17 | 18 | void SetUp() final {} 19 | 20 | void TearDown() final {} 21 | 22 | }; 23 | 24 | #endif // WIZTK_TEST_BASE_DELEGATE_HPP_ 25 | -------------------------------------------------------------------------------- /test/wiztk/base/deque/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2017 - 2018 The WizTK Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | file(GLOB sources "*.cpp") 16 | file(GLOB headers "*.hpp") 17 | 18 | add_executable(base-deque ${sources} ${headers}) 19 | target_link_libraries(base-deque ${GTEST_LIBRARIES} wiztk-base) -------------------------------------------------------------------------------- /test/wiztk/base/deque/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include 6 | 7 | int main(int argc, char *argv[]) { 8 | testing::InitGoogleTest(&argc, argv); 9 | return RUN_ALL_TESTS(); 10 | } -------------------------------------------------------------------------------- /test/wiztk/base/deque/test-deque.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #ifndef SKLAND_TEST_BASE_DEQUE_HPP_ 6 | #define SKLAND_TEST_BASE_DEQUE_HPP_ 7 | 8 | #include 9 | 10 | class TestDeque : public testing::Test { 11 | 12 | public: 13 | 14 | TestDeque() = default; 15 | 16 | ~TestDeque() override = default; 17 | 18 | protected: 19 | 20 | void SetUp() final {} 21 | 22 | void TearDown() final {} 23 | 24 | }; 25 | 26 | #endif //WAYLAND_TOOLKIT_TEST_HPP 27 | -------------------------------------------------------------------------------- /test/wiztk/base/margin/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2017 - 2018 The WizTK Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | file(GLOB sources "*.cpp") 16 | file(GLOB headers "*.hpp") 17 | 18 | add_executable(base-margin ${sources} ${headers}) 19 | target_link_libraries(base-margin ${GTEST_LIBRARIES} wiztk-base) -------------------------------------------------------------------------------- /test/wiztk/base/margin/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include 6 | 7 | int main(int argc, char *argv[]) { 8 | testing::InitGoogleTest(&argc, argv); 9 | return RUN_ALL_TESTS(); 10 | } -------------------------------------------------------------------------------- /test/wiztk/base/margin/test.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include "test.hpp" 6 | 7 | #include 8 | 9 | using Margin = wiztk::base::ThicknessI; 10 | 11 | Test::Test() 12 | : testing::Test() { 13 | } 14 | 15 | Test::~Test() { 16 | 17 | } 18 | 19 | TEST_F(Test, constructor_1) { 20 | Margin m; 21 | 22 | ASSERT_TRUE(m.left == 0 && m.right == 0 && m.top == 0 && m.bottom == 0); 23 | } 24 | 25 | TEST_F(Test, constructor_2) { 26 | Margin m(1, 2, 3, 4); 27 | 28 | ASSERT_TRUE(m.left == 1 && m.top == 2 && m.right == 3 && m.bottom == 4); 29 | } 30 | 31 | TEST_F(Test, compare_1) { 32 | Margin m1(1, 2, 3, 4); 33 | Margin m2(1, 2, 3, 4); 34 | 35 | ASSERT_TRUE(m1 == m2); 36 | } 37 | 38 | TEST_F(Test, compare_2) { 39 | Margin m1(1, 2, 3, 4); 40 | Margin m2; 41 | 42 | ASSERT_TRUE(m1 != m2); 43 | } 44 | -------------------------------------------------------------------------------- /test/wiztk/base/margin/test.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #ifndef SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 6 | #define SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 7 | 8 | #include 9 | 10 | class Test : public testing::Test { 11 | public: 12 | Test(); 13 | virtual ~Test(); 14 | 15 | protected: 16 | virtual void SetUp() {} 17 | virtual void TearDown() {} 18 | }; 19 | 20 | #endif //WAYLAND_TOOLKIT_TEST_HPP 21 | -------------------------------------------------------------------------------- /test/wiztk/base/memory/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2017 - 2018 The WizTK Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | file(GLOB sources "*.cpp") 16 | file(GLOB headers "*.hpp") 17 | 18 | add_executable(base-memory ${sources} ${headers}) 19 | target_link_libraries(base-memory ${GTEST_LIBRARIES} wiztk-base) -------------------------------------------------------------------------------- /test/wiztk/base/memory/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Freeman Zhang 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 | #include 18 | 19 | int main(int argc, char *argv[]) { 20 | testing::InitGoogleTest(&argc, argv); 21 | return RUN_ALL_TESTS(); 22 | } -------------------------------------------------------------------------------- /test/wiztk/base/memory/test-ref-counted-base.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Freeman Zhang 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 | #include "test-ref-counted-base.hpp" 18 | 19 | #include "wiztk/base/memory/ref-counted-base.hpp" 20 | 21 | using namespace wiztk; 22 | using namespace wiztk::base; 23 | 24 | /** 25 | * @brief Make sure have the same memory size 26 | */ 27 | //TEST_F(TestRefCountedBase, count_1) { 28 | // RefCountedBase<> obj; 29 | // ASSERT_TRUE(obj.use_count() == 0 && obj.weak_count() == 0); 30 | //} 31 | -------------------------------------------------------------------------------- /test/wiztk/base/memory/test-ref-counted-base.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Freeman Zhang 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 | #ifndef WIZTK_TEST_BASE_MEMORY_REF_COUNTED_BASE_HPP_ 18 | #define WIZTK_TEST_BASE_MEMORY_REF_COUNTED_BASE_HPP_ 19 | 20 | #include 21 | 22 | class TestRefCountedBase : public testing::Test { 23 | 24 | public: 25 | 26 | TestRefCountedBase() = default; 27 | 28 | ~TestRefCountedBase() override = default; 29 | 30 | protected: 31 | 32 | void SetUp() final {} 33 | 34 | void TearDown() final {} 35 | 36 | }; 37 | 38 | #endif // SKLAND_TEST_CORE_MEMORY_SP_COUNTED_BASE_HPP_ 39 | -------------------------------------------------------------------------------- /test/wiztk/base/memory/test-shared-ptr.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Freeman Zhang 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 | #ifndef WIZTK_TEST_BASE_MEMORY_SHARED_PTR_HPP_ 18 | #define WIZTK_TEST_BASE_MEMORY_SHARED_PTR_HPP_ 19 | 20 | #include 21 | 22 | class TestSharedPtr : public testing::Test { 23 | 24 | public: 25 | 26 | TestSharedPtr() = default; 27 | 28 | ~TestSharedPtr() override = default; 29 | 30 | protected: 31 | 32 | void SetUp() final {} 33 | 34 | void TearDown() final {} 35 | 36 | }; 37 | 38 | #endif //SKLAND_SHARED_PTR_HPP 39 | -------------------------------------------------------------------------------- /test/wiztk/base/memory/test-singleton.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #ifndef WIZTK_TEST_BASE_MEMORY_SINGLETON_HPP_ 18 | #define WIZTK_TEST_BASE_MEMORY_SINGLETON_HPP_ 19 | 20 | #include 21 | 22 | class TestSingleton : public testing::Test { 23 | 24 | public: 25 | 26 | TestSingleton() = default; 27 | 28 | ~TestSingleton() override = default; 29 | 30 | protected: 31 | 32 | void SetUp() final {} 33 | 34 | void TearDown() final {} 35 | 36 | }; 37 | 38 | #endif // WIZTK_TEST_BASE_MEMORY_SINGLETON_HPP_ 39 | -------------------------------------------------------------------------------- /test/wiztk/base/memory/test-weak-ptr.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #ifndef WIZTK_TEST_BASE_WEAK_PTR_HPP_ 18 | #define WIZTK_TEST_BASE_WEAK_PTR_HPP_ 19 | 20 | #include 21 | 22 | class TestWeakPtr : public testing::Test { 23 | 24 | public: 25 | 26 | TestWeakPtr() = default; 27 | 28 | ~TestWeakPtr() override = default; 29 | 30 | protected: 31 | 32 | void SetUp() final {} 33 | 34 | void TearDown() final {} 35 | 36 | }; 37 | 38 | #endif // SKLAND_TEST_CORE_WEAK_PTR_HPP_ 39 | -------------------------------------------------------------------------------- /test/wiztk/base/object/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2017 - 2018 The WizTK Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | file(GLOB sources "*.cpp") 16 | file(GLOB headers "*.hpp") 17 | 18 | add_executable(base-object ${sources} ${headers}) 19 | target_link_libraries(base-object ${GTEST_LIBRARIES} wiztk-base) -------------------------------------------------------------------------------- /test/wiztk/base/object/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include 6 | 7 | int main(int argc, char *argv[]) { 8 | testing::InitGoogleTest(&argc, argv); 9 | return RUN_ALL_TESTS(); 10 | } -------------------------------------------------------------------------------- /test/wiztk/base/rect/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2017 - 2018 The WizTK Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | file(GLOB sources "*.cpp") 16 | file(GLOB headers "*.hpp") 17 | 18 | add_executable(base-rect ${sources} ${headers}) 19 | target_link_libraries(base-rect ${GTEST_LIBRARIES} wiztk-base) -------------------------------------------------------------------------------- /test/wiztk/base/rect/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include 6 | 7 | int main(int argc, char *argv[]) { 8 | testing::InitGoogleTest(&argc, argv); 9 | return RUN_ALL_TESTS(); 10 | } -------------------------------------------------------------------------------- /test/wiztk/base/rect/test.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #ifndef SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 6 | #define SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 7 | 8 | #include 9 | 10 | class Test : public testing::Test { 11 | public: 12 | Test(); 13 | virtual ~Test(); 14 | 15 | protected: 16 | virtual void SetUp() {} 17 | virtual void TearDown() {} 18 | }; 19 | 20 | #endif //WAYLAND_TOOLKIT_TEST_HPP 21 | -------------------------------------------------------------------------------- /test/wiztk/base/sigcxx/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2017 - 2018 The WizTK Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | file(GLOB sources "*.cpp") 16 | file(GLOB headers "*.hpp") 17 | 18 | add_executable(base-sigcxx ${sources} ${headers}) 19 | target_link_libraries(base-sigcxx ${GTEST_LIBRARIES} wiztk-base) -------------------------------------------------------------------------------- /test/wiztk/base/sigcxx/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include 6 | 7 | int main(int argc, char *argv[]) { 8 | testing::InitGoogleTest(&argc, argv); 9 | return RUN_ALL_TESTS(); 10 | } -------------------------------------------------------------------------------- /test/wiztk/base/sigcxx/observer.cpp: -------------------------------------------------------------------------------- 1 | #include "observer.hpp" 2 | 3 | #include "iostream" 4 | 5 | Observer::Observer() { 6 | std::cout << __func__ << std::endl; 7 | } 8 | 9 | Observer::~Observer() { 10 | std::cout << __func__ << std::endl; 11 | } 12 | 13 | void Observer::OnCount1(int count, wiztk::base::SLOT slot) { 14 | count1_ = count; 15 | } 16 | 17 | void Observer::OnCount2(int count1, int count2, wiztk::base::SLOT slot) { 18 | count2_[0] = count1; 19 | count2_[1] = count2; 20 | } 21 | 22 | void Observer::OnUnbindSlot(int, wiztk::base::SLOT slot) { 23 | UnbindSignal(slot); 24 | } 25 | 26 | void Observer::OnUnbindAllSignals(int, wiztk::base::SLOT slot) { 27 | UnbindAllSignals(); 28 | } 29 | 30 | void Observer::OnDeleteThis(int, wiztk::base::SLOT slot) { 31 | delete this; 32 | } 33 | -------------------------------------------------------------------------------- /test/wiztk/base/sigcxx/observer.hpp: -------------------------------------------------------------------------------- 1 | #ifndef WIZTK_TEST_BASE_SIGCXX_OBSERVER_HPP_ 2 | #define WIZTK_TEST_BASE_SIGCXX_OBSERVER_HPP_ 3 | 4 | #include 5 | 6 | #include "wiztk/base/sigcxx.hpp" 7 | 8 | class Observer : public wiztk::base::Trackable { 9 | 10 | public: 11 | 12 | Observer(); 13 | 14 | ~Observer() final; 15 | 16 | void OnCount1(int, __SLOT__); 17 | 18 | void OnCount2(int, int, __SLOT__); 19 | 20 | void OnUnbindSlot(int, __SLOT__); 21 | 22 | void OnUnbindAllSignals(int, __SLOT__); 23 | 24 | /** 25 | * @brief Delete this object when called 26 | * @param slot 27 | */ 28 | void OnDeleteThis(int, __SLOT__); 29 | 30 | int count1() const { return count1_; } 31 | 32 | const std::vector &count2() const { return count2_; } 33 | 34 | private: 35 | 36 | int count1_ = 0; 37 | 38 | std::vector count2_ = {0, 0}; 39 | 40 | }; 41 | 42 | #endif // WIZTK_TEST_BASE_SIGCXX_OBSERVER_HPP_ 43 | -------------------------------------------------------------------------------- /test/wiztk/base/sigcxx/subject.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 17-9-7. 3 | // 4 | 5 | #include "subject.hpp" 6 | -------------------------------------------------------------------------------- /test/wiztk/base/sigcxx/subject.hpp: -------------------------------------------------------------------------------- 1 | #ifndef WIZTK_TEST_BASE_SIGCXX_SUBJECT_HPP_ 2 | #define WIZTK_TEST_BASE_SIGCXX_SUBJECT_HPP_ 3 | 4 | #include "wiztk/base/sigcxx.hpp" 5 | 6 | class Subject : public wiztk::base::Trackable { 7 | 8 | public: 9 | 10 | template 11 | using SignalRef = typename wiztk::base::SignalRef; 12 | 13 | template 14 | using Signal = typename wiztk::base::Signal; 15 | 16 | Subject() = default; 17 | 18 | ~Subject() final = default; 19 | 20 | SignalRef count1() { return count1_; } 21 | 22 | SignalRef count2() { return count2_; }; 23 | 24 | void DoCount1(int count) { count1_.Emit(count); } 25 | 26 | void DoCount2(int count1, int count2) { count2_.Emit(count1, count2); } 27 | 28 | private: 29 | 30 | Signal count1_; 31 | Signal count2_; 32 | 33 | }; 34 | 35 | #endif // WIZTK_TEST_BASE_SIGCXX_SUBJECT_HPP_ 36 | -------------------------------------------------------------------------------- /test/wiztk/base/sigcxx/trackable-test.hpp: -------------------------------------------------------------------------------- 1 | #ifndef WIZTK_TEST_BASE_SIGCXX_TRACKABLE_HPP_ 2 | #define WIZTK_TEST_BASE_SIGCXX_TRACKABLE_HPP_ 3 | 4 | #include 5 | 6 | class TrackableTest : public testing::Test { 7 | 8 | public: 9 | 10 | TrackableTest() = default; 11 | 12 | ~TrackableTest() override = default; 13 | 14 | protected: 15 | 16 | void SetUp() final {} 17 | 18 | void TearDown() final {} 19 | 20 | }; 21 | 22 | #endif // WIZTK_TEST_BASE_SIGCXX_TRACKABLE_HPP_ 23 | -------------------------------------------------------------------------------- /test/wiztk/base/string/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2017 - 2018 The WizTK Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | file(GLOB sources "*.cpp") 16 | file(GLOB headers "*.hpp") 17 | 18 | add_executable(base-string ${sources} ${headers}) 19 | target_link_libraries(base-string ${GTEST_LIBRARIES} wiztk-base) -------------------------------------------------------------------------------- /test/wiztk/base/string/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include 6 | 7 | int main(int argc, char *argv[]) { 8 | testing::InitGoogleTest(&argc, argv); 9 | return RUN_ALL_TESTS(); 10 | } -------------------------------------------------------------------------------- /test/wiztk/base/string/test-string-piece.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 17-11-14. 3 | // 4 | 5 | #ifndef WIZTK_TEST_STRING_PIECE_HPP 6 | #define WIZTK_TEST_STRING_PIECE_HPP 7 | 8 | #include 9 | 10 | class TestStringPiece : public testing::Test { 11 | 12 | public: 13 | 14 | TestStringPiece() = default; 15 | 16 | ~TestStringPiece() override = default; 17 | 18 | protected: 19 | 20 | void SetUp() override {} 21 | 22 | void TearDown() override {} 23 | 24 | }; 25 | 26 | #endif //WIZTK_TEST_STRING_PIECE_HPP 27 | -------------------------------------------------------------------------------- /test/wiztk/base/string/test-string.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include "test-string.hpp" 6 | 7 | #include 8 | #include "wiztk/base/string.hpp" 9 | 10 | #include 11 | 12 | using namespace wiztk; 13 | using namespace wiztk::base; 14 | 15 | TEST_F(TestString, print_1) { 16 | 17 | String str16(u"汉字"); 18 | 19 | String str32(U"汉字"); 20 | 21 | std::cout << "Print: " << str16 << std::endl; 22 | std::cout << "Print: " << str32 << std::endl; 23 | 24 | ASSERT_TRUE(true); 25 | } 26 | -------------------------------------------------------------------------------- /test/wiztk/base/string/test-string.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #ifndef WIZTK_TEST_BASE_MEMORY_REF_COUNTED_BASE_HPP_ 6 | #define WIZTK_TEST_BASE_MEMORY_REF_COUNTED_BASE_HPP_ 7 | 8 | #include 9 | 10 | class TestString : public testing::Test { 11 | 12 | public: 13 | 14 | TestString() = default; 15 | 16 | ~TestString() override = default; 17 | 18 | protected: 19 | 20 | void SetUp() override {} 21 | 22 | void TearDown() override {} 23 | 24 | }; 25 | 26 | #endif //WAYLAND_TOOLKIT_TEST_HPP 27 | -------------------------------------------------------------------------------- /test/wiztk/base/trace/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2017 - 2018 The WizTK Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | file(GLOB sources "*.cpp") 16 | file(GLOB headers "*.hpp") 17 | 18 | add_executable(base-trace ${sources} ${headers}) 19 | target_link_libraries(base-trace ${GTEST_LIBRARIES} wiztk-base) -------------------------------------------------------------------------------- /test/wiztk/base/trace/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include 6 | 7 | int main(int argc, char *argv[]) { 8 | testing::InitGoogleTest(&argc, argv); 9 | return RUN_ALL_TESTS(); 10 | } -------------------------------------------------------------------------------- /test/wiztk/base/trace/test.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include "test.hpp" 6 | 7 | #include 8 | 9 | using namespace wiztk; 10 | 11 | Test::Test() 12 | : testing::Test() { 13 | } 14 | 15 | Test::~Test() { 16 | 17 | } 18 | 19 | class TestCase { 20 | 21 | public: 22 | 23 | TestCase() {} 24 | 25 | ~TestCase() {} 26 | 27 | void TestDepth1() { 28 | Trace trace(__PRETTY_FUNCTION__, "%s", "Test depth 1"); 29 | TestDepth2(); 30 | } 31 | 32 | void TestDepth2() { 33 | Trace trace(__PRETTY_FUNCTION__, "%s", "Test depth 2"); 34 | TestDepth3(); 35 | } 36 | 37 | void TestDepth3() { 38 | Trace trace(__PRETTY_FUNCTION__, "%s", "Test depth 3"); 39 | } 40 | 41 | }; 42 | 43 | TEST_F(Test, constructor_1) { 44 | TestCase t; 45 | t.TestDepth1(); 46 | 47 | _TRACE("%s", "Another message"); 48 | 49 | ASSERT_TRUE(true); 50 | } 51 | -------------------------------------------------------------------------------- /test/wiztk/base/trace/test.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #ifndef SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 6 | #define SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 7 | 8 | #include 9 | 10 | class Test : public testing::Test { 11 | public: 12 | Test(); 13 | virtual ~Test(); 14 | 15 | protected: 16 | virtual void SetUp() {} 17 | virtual void TearDown() {} 18 | }; 19 | 20 | #endif //WAYLAND_TOOLKIT_TEST_HPP 21 | -------------------------------------------------------------------------------- /test/wiztk/base/vectors/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2017 - 2018 The WizTK Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | file(GLOB sources "*.cpp") 16 | file(GLOB headers "*.hpp") 17 | 18 | add_executable(base-vectors ${sources} ${headers}) 19 | target_link_libraries(base-vectors ${GTEST_LIBRARIES} wiztk-base) 20 | -------------------------------------------------------------------------------- /test/wiztk/base/vectors/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include 6 | 7 | int main(int argc, char *argv[]) { 8 | testing::InitGoogleTest(&argc, argv); 9 | return RUN_ALL_TESTS(); 10 | } -------------------------------------------------------------------------------- /test/wiztk/base/vectors/test.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include "test.hpp" 6 | 7 | #include 8 | 9 | using namespace wiztk::base; 10 | typedef Vector2 vec2i; 11 | 12 | Test::Test() 13 | : testing::Test() { 14 | } 15 | 16 | Test::~Test() { 17 | 18 | } 19 | 20 | TEST_F(Test, Vector2_1) { 21 | vec2i v1 {1, 1}; 22 | vec2i v2 {2, 2}; 23 | vec2i v3 {1, 1}; 24 | 25 | ASSERT_TRUE(v1 == v3 && v1 != v2); 26 | } 27 | 28 | TEST_F(Test, Vector2_2) { 29 | vec2i v1 {1, 1}; 30 | vec2i v2 {2, 2}; 31 | 32 | vec2i v3 = v1 + v2; 33 | 34 | ASSERT_TRUE(v3.x == 3 && v3.y == 3); 35 | } 36 | -------------------------------------------------------------------------------- /test/wiztk/base/vectors/test.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #ifndef SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 6 | #define SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 7 | 8 | #include 9 | 10 | class Test : public testing::Test { 11 | public: 12 | Test(); 13 | virtual ~Test(); 14 | 15 | protected: 16 | virtual void SetUp() {} 17 | virtual void TearDown() {} 18 | }; 19 | 20 | #endif //WAYLAND_TOOLKIT_TEST_HPP 21 | -------------------------------------------------------------------------------- /test/wiztk/device/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2017 - 2018 The WizTK Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | add_subdirectory(video/camera) -------------------------------------------------------------------------------- /test/wiztk/device/video/camera/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2017 - 2018 The WizTK Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | file(GLOB sources "*.cpp") 16 | file(GLOB headers "*.hpp") 17 | 18 | add_executable(device-video-camera ${sources} ${headers}) 19 | target_link_libraries(device-video-camera ${GTEST_LIBRARIES} wiztk-device) -------------------------------------------------------------------------------- /test/wiztk/device/video/camera/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include 6 | 7 | int main(int argc, char *argv[]) { 8 | testing::InitGoogleTest(&argc, argv); 9 | return RUN_ALL_TESTS(); 10 | } -------------------------------------------------------------------------------- /test/wiztk/device/video/camera/test-camera.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include "test-camera.hpp" 6 | 7 | #include 8 | 9 | using namespace wiztk; 10 | using namespace wiztk::device; 11 | 12 | TEST_F(TestCamera, query_all_1) { 13 | video::Camera::GetAll(); 14 | 15 | ASSERT_TRUE(true); 16 | } -------------------------------------------------------------------------------- /test/wiztk/device/video/camera/test-camera.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #ifndef WIZTK_TEST_DEVICE_VIDEO_CAMERA_HPP_ 6 | #define WIZTK_TEST_DEVICE_VIDEO_CAMERA_HPP_ 7 | 8 | #include 9 | 10 | class TestCamera : public testing::Test { 11 | 12 | public: 13 | 14 | TestCamera() = default; 15 | 16 | ~TestCamera() override = default; 17 | 18 | protected: 19 | 20 | void SetUp() final {} 21 | 22 | void TearDown() final {} 23 | 24 | }; 25 | 26 | #endif // WIZTK_TEST_DEVICE_VIDEO_CAMERA_HPP_ 27 | -------------------------------------------------------------------------------- /test/wiztk/graphics/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Freeman Zhang 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) 16 | 17 | # graphics 18 | add_subdirectory(font) 19 | add_subdirectory(font-style) 20 | add_subdirectory(color-space) 21 | add_subdirectory(image-info) 22 | add_subdirectory(gradient-shader) 23 | add_subdirectory(path) 24 | add_subdirectory(typeface) 25 | add_subdirectory(paint) 26 | add_subdirectory(canvas) 27 | 28 | -------------------------------------------------------------------------------- /test/wiztk/graphics/canvas/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Freeman Zhang 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | file(GLOB sources "*.cpp") 16 | file(GLOB headers "*.hpp") 17 | 18 | add_executable(graphics-canvas ${sources} ${headers}) 19 | target_link_libraries(graphics-canvas ${GTEST_LIBRARIES} wiztk-graphics) -------------------------------------------------------------------------------- /test/wiztk/graphics/canvas/draw-test.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Freeman Zhang 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 | #ifndef SKLAND_DRAW_HPP 18 | #define SKLAND_DRAW_HPP 19 | 20 | #include 21 | 22 | class DrawTest : public testing::Test { 23 | public: 24 | DrawTest(); 25 | virtual ~DrawTest(); 26 | 27 | protected: 28 | virtual void SetUp() {} 29 | virtual void TearDown() {} 30 | }; 31 | 32 | #endif //SKLAND_DRAW_HPP 33 | -------------------------------------------------------------------------------- /test/wiztk/graphics/canvas/flush-test.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 17-9-8. 3 | // 4 | 5 | #ifndef SKLAND_FLUSH_TEST_HPP 6 | #define SKLAND_FLUSH_TEST_HPP 7 | 8 | #include 9 | 10 | class FlushTest : public testing::Test { 11 | 12 | public: 13 | 14 | FlushTest() {} 15 | 16 | virtual ~FlushTest() {} 17 | 18 | protected: 19 | 20 | virtual void SetUp() {} 21 | 22 | virtual void TearDown() {} 23 | 24 | }; 25 | 26 | #endif //SKLAND_FLUSH_TEST_HPP 27 | -------------------------------------------------------------------------------- /test/wiztk/graphics/canvas/lock-guard-test.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 17-8-25. 3 | // 4 | 5 | #ifndef SKLAND_LOCKGUARDTEST_HPP 6 | #define SKLAND_LOCKGUARDTEST_HPP 7 | 8 | #include 9 | 10 | class LockGuardTest : public testing::Test { 11 | 12 | public: 13 | 14 | LockGuardTest(); 15 | 16 | virtual ~LockGuardTest(); 17 | 18 | protected: 19 | 20 | virtual void SetUp() {} 21 | 22 | virtual void TearDown() {} 23 | 24 | }; 25 | 26 | #endif //SKLAND_LOCKGUARDTEST_HPP 27 | -------------------------------------------------------------------------------- /test/wiztk/graphics/canvas/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include 6 | 7 | int main(int argc, char *argv[]) { 8 | testing::InitGoogleTest(&argc, argv); 9 | return RUN_ALL_TESTS(); 10 | } -------------------------------------------------------------------------------- /test/wiztk/graphics/canvas/matrix-test.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #ifndef WIZTK_TEST_BASE_MEMORY_REF_COUNTED_BASE_HPP_ 6 | #define WIZTK_TEST_BASE_MEMORY_REF_COUNTED_BASE_HPP_ 7 | 8 | #include 9 | 10 | class MatrixTest : public testing::Test { 11 | public: 12 | MatrixTest(); 13 | virtual ~MatrixTest(); 14 | 15 | protected: 16 | virtual void SetUp() {} 17 | virtual void TearDown() {} 18 | }; 19 | 20 | #endif //WAYLAND_TOOLKIT_TEST_HPP 21 | -------------------------------------------------------------------------------- /test/wiztk/graphics/canvas/stack-test.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Freeman Zhang 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 | #ifndef SKLAND_STACK_TEST_HPP 18 | #define SKLAND_STACK_TEST_HPP 19 | 20 | #include 21 | 22 | class StackTest : public testing::Test { 23 | public: 24 | StackTest() {} 25 | virtual ~StackTest() {} 26 | 27 | protected: 28 | virtual void SetUp() {} 29 | virtual void TearDown() {} 30 | }; 31 | 32 | #endif //SKLAND_STACK_TEST_HPP 33 | -------------------------------------------------------------------------------- /test/wiztk/graphics/color-space/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Freeman Zhang 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | file(GLOB sources "*.cpp") 16 | file(GLOB headers "*.hpp") 17 | 18 | add_executable(graphics-color-space ${sources} ${headers}) 19 | target_link_libraries(graphics-color-space ${GTEST_LIBRARIES} wiztk-graphics) -------------------------------------------------------------------------------- /test/wiztk/graphics/color-space/color-space-test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #include "color-space-test.hpp" 18 | 19 | #include 20 | 21 | #include "SkColorSpace.h" 22 | 23 | using namespace wiztk::graphics; 24 | 25 | TEST_F(ColorSpaceTest, color_space_gamut_enum) { 26 | 27 | // Compare Font::Weight and SkFontStyle::Weight 28 | ASSERT_TRUE((int) ColorSpace::GamutType::kGamutSRGB == (int) SkColorSpace::Gamut::kSRGB_Gamut); 29 | ASSERT_TRUE((int) ColorSpace::GamutType::kGamutAdobeRGB == (int) SkColorSpace::Gamut::kAdobeRGB_Gamut); 30 | ASSERT_TRUE((int) ColorSpace::GamutType::kGamutDCIP3_D65 == (int) SkColorSpace::Gamut::kDCIP3_D65_Gamut); 31 | ASSERT_TRUE((int) ColorSpace::GamutType::kGamutRec2020 == (int) SkColorSpace::Gamut::kRec2020_Gamut); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /test/wiztk/graphics/color-space/color-space-test.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #ifndef WIZTK_GRAPHICS_IMAGE_INFO_TEST_HPP_ 18 | #define WIZTK_GRAPHICS_IMAGE_INFO_TEST_HPP_ 19 | 20 | #include 21 | 22 | class ColorSpaceTest : public testing::Test { 23 | public: 24 | ColorSpaceTest() = default; 25 | ~ColorSpaceTest() override = default; 26 | 27 | protected: 28 | void SetUp() override {} 29 | void TearDown() override {} 30 | }; 31 | 32 | #endif //WAYLAND_TOOLKIT_TEST_HPP 33 | -------------------------------------------------------------------------------- /test/wiztk/graphics/color-space/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include 6 | 7 | int main(int argc, char *argv[]) { 8 | testing::InitGoogleTest(&argc, argv); 9 | return RUN_ALL_TESTS(); 10 | } -------------------------------------------------------------------------------- /test/wiztk/graphics/font-style/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2017 - 2018 The WizTK Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | file(GLOB sources "*.cpp") 16 | file(GLOB headers "*.hpp") 17 | 18 | add_executable(graphics-font-style ${sources} ${headers}) 19 | target_link_libraries(graphics-font-style ${GTEST_LIBRARIES} wiztk-graphics) -------------------------------------------------------------------------------- /test/wiztk/graphics/font-style/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include 6 | 7 | int main(int argc, char *argv[]) { 8 | testing::InitGoogleTest(&argc, argv); 9 | return RUN_ALL_TESTS(); 10 | } -------------------------------------------------------------------------------- /test/wiztk/graphics/font-style/test.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #ifndef SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 6 | #define SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 7 | 8 | #include 9 | 10 | class Test : public testing::Test { 11 | public: 12 | Test(); 13 | virtual ~Test(); 14 | 15 | protected: 16 | virtual void SetUp() {} 17 | virtual void TearDown() {} 18 | }; 19 | 20 | #endif //WAYLAND_TOOLKIT_TEST_HPP 21 | -------------------------------------------------------------------------------- /test/wiztk/graphics/font/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2017 - 2018 The WizTK Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | file(GLOB sources "*.cpp") 16 | file(GLOB headers "*.hpp") 17 | 18 | add_executable(graphics-font ${sources} ${headers}) 19 | target_link_libraries(graphics-font ${GTEST_LIBRARIES} wiztk-graphics) -------------------------------------------------------------------------------- /test/wiztk/graphics/font/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include 6 | 7 | int main(int argc, char *argv[]) { 8 | testing::InitGoogleTest(&argc, argv); 9 | return RUN_ALL_TESTS(); 10 | } -------------------------------------------------------------------------------- /test/wiztk/graphics/font/test.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #ifndef SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 6 | #define SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 7 | 8 | #include 9 | 10 | class Test : public testing::Test { 11 | public: 12 | Test(); 13 | virtual ~Test(); 14 | 15 | protected: 16 | virtual void SetUp() {} 17 | virtual void TearDown() {} 18 | }; 19 | 20 | #endif //WAYLAND_TOOLKIT_TEST_HPP 21 | -------------------------------------------------------------------------------- /test/wiztk/graphics/gradient-shader/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2017 - 2018 The WizTK Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | file(GLOB sources "*.cpp") 16 | file(GLOB headers "*.hpp") 17 | 18 | add_executable(graphics-gradient-shader ${sources} ${headers}) 19 | target_link_libraries(graphics-gradient-shader ${GTEST_LIBRARIES} wiztk-graphics) -------------------------------------------------------------------------------- /test/wiztk/graphics/gradient-shader/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Freeman Zhang 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 | #include 18 | 19 | int main(int argc, char *argv[]) { 20 | testing::InitGoogleTest(&argc, argv); 21 | return RUN_ALL_TESTS(); 22 | } -------------------------------------------------------------------------------- /test/wiztk/graphics/gradient-shader/test.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Freeman Zhang 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 | #ifndef SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 18 | #define SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 19 | 20 | #include 21 | 22 | class Test : public testing::Test { 23 | public: 24 | Test(); 25 | virtual ~Test(); 26 | 27 | protected: 28 | virtual void SetUp() {} 29 | virtual void TearDown() {} 30 | }; 31 | 32 | #endif //WAYLAND_TOOLKIT_TEST_HPP 33 | -------------------------------------------------------------------------------- /test/wiztk/graphics/image-info/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Freeman Zhang 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | file(GLOB sources "*.cpp") 16 | file(GLOB headers "*.hpp") 17 | 18 | add_executable(graphics-image-info ${sources} ${headers}) 19 | target_link_libraries(graphics-image-info ${GTEST_LIBRARIES} wiztk-graphics) -------------------------------------------------------------------------------- /test/wiztk/graphics/image-info/image-info-test.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #ifndef WIZTK_GRAPHICS_IMAGE_INFO_TEST_HPP_ 18 | #define WIZTK_GRAPHICS_IMAGE_INFO_TEST_HPP_ 19 | 20 | #include 21 | 22 | class ImageInfoTest : public testing::Test { 23 | public: 24 | ImageInfoTest() = default; 25 | ~ImageInfoTest() override = default; 26 | 27 | protected: 28 | void SetUp() override {} 29 | void TearDown() override {} 30 | }; 31 | 32 | #endif // WIZTK_GRAPHICS_IMAGE_INFO_TEST_HPP_ 33 | -------------------------------------------------------------------------------- /test/wiztk/graphics/image-info/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include 6 | 7 | int main(int argc, char *argv[]) { 8 | testing::InitGoogleTest(&argc, argv); 9 | return RUN_ALL_TESTS(); 10 | } -------------------------------------------------------------------------------- /test/wiztk/graphics/paint/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Freeman Zhang 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | file(GLOB sources "*.cpp") 16 | file(GLOB headers "*.hpp") 17 | 18 | add_executable(graphics-paint ${sources} ${headers}) 19 | target_link_libraries(graphics-paint ${GTEST_LIBRARIES} wiztk-graphics) -------------------------------------------------------------------------------- /test/wiztk/graphics/paint/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Freeman Zhang 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 | #include 18 | 19 | int main(int argc, char *argv[]) { 20 | testing::InitGoogleTest(&argc, argv); 21 | return RUN_ALL_TESTS(); 22 | } -------------------------------------------------------------------------------- /test/wiztk/graphics/paint/test.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Freeman Zhang 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 | #ifndef SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 18 | #define SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 19 | 20 | #include 21 | 22 | class Test : public testing::Test { 23 | public: 24 | Test(); 25 | virtual ~Test(); 26 | 27 | protected: 28 | virtual void SetUp() {} 29 | virtual void TearDown() {} 30 | }; 31 | 32 | #endif //WAYLAND_TOOLKIT_TEST_HPP 33 | -------------------------------------------------------------------------------- /test/wiztk/graphics/path/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Freeman Zhang 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | file(GLOB sources "*.cpp") 16 | file(GLOB headers "*.hpp") 17 | 18 | add_executable(graphics-path ${sources} ${headers}) 19 | target_link_libraries(graphics-path ${GTEST_LIBRARIES} wiztk-graphics) -------------------------------------------------------------------------------- /test/wiztk/graphics/path/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include 6 | 7 | int main(int argc, char *argv[]) { 8 | testing::InitGoogleTest(&argc, argv); 9 | return RUN_ALL_TESTS(); 10 | } -------------------------------------------------------------------------------- /test/wiztk/graphics/path/path-test.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include "path-test.hpp" 6 | 7 | #include 8 | #include "SkPath.h" 9 | 10 | using namespace wiztk::graphics; 11 | 12 | TEST_F(PathTest, enums_check_1) { 13 | 14 | // Direction 15 | ASSERT_TRUE((int) Path::Direction::kClockwise == (int) SkPath::Direction::kCW_Direction); 16 | ASSERT_TRUE((int) Path::Direction::kCounterClockwise == (int) SkPath::Direction::kCCW_Direction); 17 | 18 | // FillType 19 | ASSERT_TRUE((int) Path::FillType::kFillTypeWinding == (int) SkPath::FillType::kWinding_FillType); 20 | ASSERT_TRUE((int) Path::FillType::kFillTypeEvenOdd == (int) SkPath::FillType::kEvenOdd_FillType); 21 | ASSERT_TRUE((int) Path::FillType::kFillTypeInverseWinding == (int) SkPath::FillType::kInverseWinding_FillType); 22 | ASSERT_TRUE((int) Path::FillType::kFillTypeInverseEvenOdd == (int) SkPath::FillType::kInverseEvenOdd_FillType); 23 | 24 | // Convexity 25 | ASSERT_TRUE((int) Path::Convexity::kConvexityUnknown == (int) SkPath::kUnknown_Convexity); 26 | ASSERT_TRUE((int) Path::Convexity::kConvexityConvex == (int) SkPath::kConvex_Convexity); 27 | ASSERT_TRUE((int) Path::Convexity::kConvexityConcave == (int) SkPath::kConcave_Convexity); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /test/wiztk/graphics/path/path-test.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #ifndef WIZTK_TEST_GRAPHICS_PATH_HPP_ 6 | #define WIZTK_TEST_GRAPHICS_PATH_HPP_ 7 | 8 | #include 9 | 10 | class PathTest : public testing::Test { 11 | public: 12 | PathTest() = default; 13 | ~PathTest() override = default; 14 | 15 | protected: 16 | void SetUp() final {} 17 | void TearDown() final {} 18 | }; 19 | 20 | #endif // WIZTK_TEST_GRAPHICS_PATH_HPP_ 21 | -------------------------------------------------------------------------------- /test/wiztk/graphics/typeface/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Freeman Zhang 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | file(GLOB sources "*.cpp") 16 | file(GLOB headers "*.hpp") 17 | 18 | add_executable(graphics-typeface ${sources} ${headers}) 19 | target_link_libraries(graphics-typeface ${GTEST_LIBRARIES} wiztk-graphics) -------------------------------------------------------------------------------- /test/wiztk/graphics/typeface/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include 6 | 7 | int main(int argc, char *argv[]) { 8 | testing::InitGoogleTest(&argc, argv); 9 | return RUN_ALL_TESTS(); 10 | } -------------------------------------------------------------------------------- /test/wiztk/graphics/typeface/test.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #ifndef SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 6 | #define SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 7 | 8 | #include 9 | 10 | class Test : public testing::Test { 11 | public: 12 | Test(); 13 | virtual ~Test(); 14 | 15 | protected: 16 | virtual void SetUp() {} 17 | virtual void TearDown() {} 18 | }; 19 | 20 | #endif //WAYLAND_TOOLKIT_TEST_HPP 21 | -------------------------------------------------------------------------------- /test/wiztk/gui/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Freeman Zhang 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) 16 | 17 | # gui 18 | add_subdirectory(display) 19 | add_subdirectory(application) 20 | add_subdirectory(output) 21 | add_subdirectory(window) 22 | add_subdirectory(dialog) 23 | add_subdirectory(timer) 24 | # add_subdirectory(gui-main-window) 25 | add_subdirectory(slider) 26 | add_subdirectory(gles2-backend) 27 | add_subdirectory(gl-view) 28 | add_subdirectory(linear-layout) 29 | add_subdirectory(relative-layout) 30 | 31 | -------------------------------------------------------------------------------- /test/wiztk/gui/application/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources "*.cpp") 2 | file(GLOB headers "*.hpp") 3 | 4 | add_executable(gui-application ${sources} ${headers}) 5 | target_link_libraries(gui-application ${GTEST_LIBRARIES} wiztk-gui) -------------------------------------------------------------------------------- /test/wiztk/gui/application/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include 6 | 7 | int main(int argc, char *argv[]) { 8 | testing::InitGoogleTest(&argc, argv); 9 | return RUN_ALL_TESTS(); 10 | } -------------------------------------------------------------------------------- /test/wiztk/gui/application/test.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include "test.hpp" 6 | 7 | #include 8 | 9 | using wiztk::gui::Application; 10 | 11 | Test::Test() 12 | : testing::Test() { 13 | } 14 | 15 | Test::~Test() { 16 | 17 | } 18 | 19 | /* 20 | * 21 | */ 22 | TEST_F(Test, application) { 23 | int argc = 1; 24 | char argv1[] = "application"; // to avoid compile warning 25 | char *argv[] = {argv1}; 26 | 27 | Application app(argc, argv); 28 | 29 | bool result1 = (app.GetArgc() == argc); 30 | bool result2 = (strcmp(app.GetArgv()[0], argv1) == 0); 31 | 32 | app.Exit(); 33 | 34 | ASSERT_TRUE(result1 && result2); 35 | } 36 | -------------------------------------------------------------------------------- /test/wiztk/gui/application/test.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #ifndef SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 6 | #define SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 7 | 8 | #include 9 | 10 | class Test : public testing::Test { 11 | public: 12 | Test(); 13 | virtual ~Test(); 14 | 15 | protected: 16 | virtual void SetUp() {} 17 | virtual void TearDown() {} 18 | }; 19 | 20 | #endif //WAYLAND_TOOLKIT_TEST_HPP 21 | -------------------------------------------------------------------------------- /test/wiztk/gui/dialog/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources "*.cpp") 2 | file(GLOB headers "*.hpp") 3 | 4 | add_executable(gui-dialog ${sources} ${headers}) 5 | target_link_libraries(gui-dialog ${GTEST_LIBRARIES} wiztk-gui) -------------------------------------------------------------------------------- /test/wiztk/gui/dialog/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Freeman Zhang 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 | #include 18 | 19 | int main(int argc, char *argv[]) { 20 | testing::InitGoogleTest(&argc, argv); 21 | return RUN_ALL_TESTS(); 22 | } -------------------------------------------------------------------------------- /test/wiztk/gui/dialog/test.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #ifndef SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 6 | #define SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 7 | 8 | #include 9 | 10 | class Test : public testing::Test { 11 | public: 12 | Test(); 13 | virtual ~Test(); 14 | 15 | protected: 16 | virtual void SetUp() {} 17 | virtual void TearDown() {} 18 | }; 19 | 20 | #endif //WAYLAND_TOOLKIT_TEST_HPP 21 | -------------------------------------------------------------------------------- /test/wiztk/gui/display/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources "*.cpp") 2 | file(GLOB headers "*.hpp") 3 | 4 | add_executable(gui-display ${sources} ${headers}) 5 | target_link_libraries(gui-display ${GTEST_LIBRARIES} wiztk-gui) -------------------------------------------------------------------------------- /test/wiztk/gui/display/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include 6 | 7 | int main(int argc, char *argv[]) { 8 | testing::InitGoogleTest(&argc, argv); 9 | return RUN_ALL_TESTS(); 10 | } -------------------------------------------------------------------------------- /test/wiztk/gui/display/test.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include "test.hpp" 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | using wiztk::gui::Application; 13 | using wiztk::gui::Display; 14 | using std::cout; 15 | using std::endl; 16 | 17 | Test::Test() 18 | : testing::Test() { 19 | } 20 | 21 | Test::~Test() { 22 | 23 | } 24 | 25 | /* 26 | * 27 | */ 28 | TEST_F(Test, application) { 29 | using wiztk::gui::Display; 30 | 31 | int argc = 1; 32 | char argv1[] = "application"; // to avoid compile warning 33 | char *argv[] = {argv1}; 34 | 35 | Application app(argc, argv); 36 | app.Exit(); 37 | 38 | ASSERT_TRUE(true); 39 | } 40 | -------------------------------------------------------------------------------- /test/wiztk/gui/display/test.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #ifndef SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 6 | #define SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 7 | 8 | #include 9 | 10 | class Test : public testing::Test { 11 | public: 12 | Test(); 13 | virtual ~Test(); 14 | 15 | protected: 16 | virtual void SetUp() {} 17 | virtual void TearDown() {} 18 | }; 19 | 20 | #endif //WAYLAND_TOOLKIT_TEST_HPP 21 | -------------------------------------------------------------------------------- /test/wiztk/gui/gl-view/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources "*.cpp") 2 | file(GLOB headers "*.hpp") 3 | 4 | add_executable(gui-gl-view ${sources} ${headers}) 5 | target_link_libraries(gui-gl-view ${GTEST_LIBRARIES} wiztk-gui) -------------------------------------------------------------------------------- /test/wiztk/gui/gl-view/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include 6 | 7 | int main(int argc, char *argv[]) { 8 | testing::InitGoogleTest(&argc, argv); 9 | return RUN_ALL_TESTS(); 10 | } -------------------------------------------------------------------------------- /test/wiztk/gui/gl-view/test.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #ifndef SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 6 | #define SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 7 | 8 | #include 9 | 10 | class Test : public testing::Test { 11 | public: 12 | Test(); 13 | virtual ~Test(); 14 | 15 | protected: 16 | virtual void SetUp() {} 17 | virtual void TearDown() {} 18 | }; 19 | 20 | #endif //WAYLAND_TOOLKIT_TEST_HPP 21 | -------------------------------------------------------------------------------- /test/wiztk/gui/gles2-backend/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources "*.cpp") 2 | file(GLOB headers "*.hpp") 3 | 4 | add_executable(gui-gles2-backend ${sources} ${headers}) 5 | target_link_libraries(gui-gles2-backend ${GTEST_LIBRARIES} wiztk-gui) -------------------------------------------------------------------------------- /test/wiztk/gui/gles2-backend/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Freeman Zhang 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 | #include 18 | 19 | int main(int argc, char *argv[]) { 20 | testing::InitGoogleTest(&argc, argv); 21 | return RUN_ALL_TESTS(); 22 | } -------------------------------------------------------------------------------- /test/wiztk/gui/gles2-backend/test-gles2-backend.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #ifndef WIZTK_TEST_GUI_GLES2_BACKEND_HPP_ 18 | #define WIZTK_TEST_GUI_GLES2_BACKEND_HPP_ 19 | 20 | #include 21 | 22 | class TestGLES2Backend : public testing::Test { 23 | public: 24 | TestGLES2Backend() = default; 25 | ~TestGLES2Backend() override = default; 26 | 27 | protected: 28 | void SetUp() final {} 29 | void TearDown() final {} 30 | }; 31 | 32 | #endif // WIZTK_TEST_GUI_GLES2_BACKEND_HPP_ 33 | -------------------------------------------------------------------------------- /test/wiztk/gui/linear-layout/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources "*.cpp") 2 | file(GLOB headers "*.hpp") 3 | 4 | add_executable(gui-linear-layout ${sources} ${headers}) 5 | target_link_libraries(gui-linear-layout ${GTEST_LIBRARIES} wiztk-gui) -------------------------------------------------------------------------------- /test/wiztk/gui/linear-layout/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Freeman Zhang 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 | #include 18 | 19 | int main(int argc, char *argv[]) { 20 | testing::InitGoogleTest(&argc, argv); 21 | return RUN_ALL_TESTS(); 22 | } -------------------------------------------------------------------------------- /test/wiztk/gui/linear-layout/test.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #ifndef SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 6 | #define SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 7 | 8 | #include 9 | 10 | class Test : public testing::Test { 11 | public: 12 | Test(); 13 | virtual ~Test(); 14 | 15 | protected: 16 | virtual void SetUp() {} 17 | virtual void TearDown() {} 18 | }; 19 | 20 | #endif //WAYLAND_TOOLKIT_TEST_HPP 21 | -------------------------------------------------------------------------------- /test/wiztk/gui/output/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources "*.cpp") 2 | file(GLOB headers "*.hpp") 3 | 4 | add_executable(gui-output ${sources} ${headers}) 5 | target_link_libraries(gui-output ${GTEST_LIBRARIES} wiztk-gui) -------------------------------------------------------------------------------- /test/wiztk/gui/output/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Freeman Zhang 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 | #include 18 | 19 | int main(int argc, char *argv[]) { 20 | testing::InitGoogleTest(&argc, argv); 21 | return RUN_ALL_TESTS(); 22 | } -------------------------------------------------------------------------------- /test/wiztk/gui/output/test-output.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 The WizTK Authors. 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 | #ifndef WIZTK_TEST_GUI_OUTPUT_HPP_ 18 | #define WIZTK_TEST_GUI_OUTPUT_HPP_ 19 | 20 | #include 21 | 22 | class TestOutput : public testing::Test { 23 | public: 24 | TestOutput() = default; 25 | ~TestOutput() override = default; 26 | 27 | protected: 28 | void SetUp() final {} 29 | void TearDown() final {} 30 | }; 31 | 32 | #endif // WIZTK_TEST_GUI_OUTPUT_HPP_ 33 | -------------------------------------------------------------------------------- /test/wiztk/gui/relative-layout/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources "*.cpp") 2 | file(GLOB headers "*.hpp") 3 | 4 | add_executable(gui-relative-layout ${sources} ${headers}) 5 | target_link_libraries(gui-relative-layout ${GTEST_LIBRARIES} wiztk-gui) -------------------------------------------------------------------------------- /test/wiztk/gui/relative-layout/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Freeman Zhang 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 | #include 18 | 19 | int main(int argc, char *argv[]) { 20 | testing::InitGoogleTest(&argc, argv); 21 | return RUN_ALL_TESTS(); 22 | } -------------------------------------------------------------------------------- /test/wiztk/gui/relative-layout/test.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #ifndef SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 6 | #define SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 7 | 8 | #include 9 | 10 | class Test : public testing::Test { 11 | public: 12 | Test(); 13 | virtual ~Test(); 14 | 15 | protected: 16 | virtual void SetUp() {} 17 | virtual void TearDown() {} 18 | }; 19 | 20 | #endif //WAYLAND_TOOLKIT_TEST_HPP 21 | -------------------------------------------------------------------------------- /test/wiztk/gui/slider/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources "*.cpp") 2 | file(GLOB headers "*.hpp") 3 | 4 | add_executable(gui-slider ${sources} ${headers}) 5 | target_link_libraries(gui-slider ${GTEST_LIBRARIES} wiztk-gui) -------------------------------------------------------------------------------- /test/wiztk/gui/slider/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include 6 | 7 | int main(int argc, char *argv[]) { 8 | testing::InitGoogleTest(&argc, argv); 9 | return RUN_ALL_TESTS(); 10 | } -------------------------------------------------------------------------------- /test/wiztk/gui/slider/test.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include "test.hpp" 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | using namespace wiztk; 12 | using namespace wiztk::gui; 13 | 14 | Test::Test() 15 | : testing::Test() { 16 | } 17 | 18 | Test::~Test() { 19 | 20 | } 21 | 22 | /* 23 | * 24 | */ 25 | TEST_F(Test, slider_1) { 26 | using wiztk::gui::Window; 27 | 28 | int argc = 1; 29 | char argv1[] = "gui-slider"; // to avoid compile warning 30 | char *argv[] = {argv1}; 31 | 32 | Application app(argc, argv); 33 | 34 | Window *win = new Window(320, 240, "Slider Test"); 35 | win->SetAppId("Test"); 36 | 37 | Slider* slider = new Slider; 38 | win->SetContentView(slider); 39 | 40 | win->Show(); 41 | 42 | int result = app.Run(); 43 | 44 | ASSERT_TRUE(result == 0); 45 | } 46 | -------------------------------------------------------------------------------- /test/wiztk/gui/slider/test.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #ifndef SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 6 | #define SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 7 | 8 | #include 9 | 10 | class Test : public testing::Test { 11 | public: 12 | Test(); 13 | virtual ~Test(); 14 | 15 | protected: 16 | virtual void SetUp() {} 17 | virtual void TearDown() {} 18 | }; 19 | 20 | #endif //WAYLAND_TOOLKIT_TEST_HPP 21 | -------------------------------------------------------------------------------- /test/wiztk/gui/timer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources "*.cpp") 2 | file(GLOB headers "*.hpp") 3 | 4 | add_executable(gui-timer ${sources} ${headers}) 5 | target_link_libraries(gui-timer ${GTEST_LIBRARIES} wiztk-gui) -------------------------------------------------------------------------------- /test/wiztk/gui/timer/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include 6 | 7 | int main(int argc, char *argv[]) { 8 | testing::InitGoogleTest(&argc, argv); 9 | return RUN_ALL_TESTS(); 10 | } -------------------------------------------------------------------------------- /test/wiztk/gui/timer/test.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #ifndef SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 6 | #define SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 7 | 8 | #include 9 | 10 | class Test : public testing::Test { 11 | public: 12 | Test(); 13 | virtual ~Test(); 14 | 15 | protected: 16 | virtual void SetUp() {} 17 | virtual void TearDown() {} 18 | }; 19 | 20 | #endif //WAYLAND_TOOLKIT_TEST_HPP 21 | -------------------------------------------------------------------------------- /test/wiztk/gui/window/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources "*.cpp") 2 | file(GLOB headers "*.hpp") 3 | 4 | add_executable(gui-window ${sources} ${headers}) 5 | target_link_libraries(gui-window ${GTEST_LIBRARIES} wiztk-gui) -------------------------------------------------------------------------------- /test/wiztk/gui/window/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Freeman Zhang 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 | #include 18 | 19 | int main(int argc, char *argv[]) { 20 | testing::InitGoogleTest(&argc, argv); 21 | return RUN_ALL_TESTS(); 22 | } -------------------------------------------------------------------------------- /test/wiztk/gui/window/test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Freeman Zhang 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 | #include "test.hpp" 18 | 19 | #include 20 | #include 21 | 22 | Test::Test() 23 | : testing::Test() { 24 | } 25 | 26 | Test::~Test() { 27 | 28 | } 29 | 30 | /** 31 | * @brief Show a default empty window 32 | * 33 | * Expected result: display and resize a default window 34 | */ 35 | TEST_F(Test, show) { 36 | using wiztk::gui::Application; 37 | using wiztk::gui::Window; 38 | 39 | int argc = 1; 40 | char argv1[] = "show"; // to avoid compile warning 41 | char *argv[] = {argv1}; 42 | 43 | Application app(argc, argv); 44 | 45 | Window win(400, 300, "Test Window"); 46 | win.Show(); 47 | 48 | int result = app.Run(); 49 | 50 | ASSERT_TRUE(result == 0); 51 | } 52 | -------------------------------------------------------------------------------- /test/wiztk/gui/window/test.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #ifndef SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 6 | #define SKLAND_TEST_CORE_SIGCXX_TRACKABLE_HPP_ 7 | 8 | #include 9 | 10 | class Test : public testing::Test { 11 | public: 12 | Test(); 13 | virtual ~Test(); 14 | 15 | protected: 16 | virtual void SetUp() {} 17 | virtual void TearDown() {} 18 | }; 19 | 20 | #endif //WAYLAND_TOOLKIT_TEST_HPP 21 | -------------------------------------------------------------------------------- /test/wiztk/net/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Freeman Zhang 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) 16 | 17 | add_subdirectory(address-info) 18 | add_subdirectory(ip-address) 19 | add_subdirectory(socket) 20 | add_subdirectory(server-socket) 21 | -------------------------------------------------------------------------------- /test/wiztk/net/address-info/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources "*.cpp") 2 | file(GLOB headers "*.hpp") 3 | 4 | add_executable(net-address-info ${sources} ${headers}) 5 | target_link_libraries(net-address-info ${GTEST_LIBRARIES} wiztk-net) -------------------------------------------------------------------------------- /test/wiztk/net/address-info/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include 6 | 7 | int main(int argc, char *argv[]) { 8 | testing::InitGoogleTest(&argc, argv); 9 | return RUN_ALL_TESTS(); 10 | } -------------------------------------------------------------------------------- /test/wiztk/net/address-info/test-address-info.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "test-address-info.hpp" 3 | 4 | #include "wiztk/net/address-info.hpp" 5 | #include "wiztk/net/ip-address.hpp" 6 | 7 | using namespace wiztk; 8 | using namespace wiztk::net; 9 | 10 | using std::cout; 11 | using std::endl; 12 | 13 | TEST_F(TestAddressInfo, getall_1) { 14 | std::unique_ptr list = AddressInfo::GetAll("www.baidu.com", "http"); 15 | 16 | for (size_t i = 0; i < list->size(); ++i) { 17 | IPAddress ip(*(*list)[i]); 18 | cout << "address: " << ip.ToString() << endl; 19 | } 20 | 21 | ASSERT_TRUE(list->size() != 0); 22 | } 23 | 24 | TEST_F(TestAddressInfo, getall_2) { 25 | std::unique_ptr list = AddressInfo::GetAll("localhost"); 26 | ASSERT_TRUE(list->size() != 0); 27 | } 28 | -------------------------------------------------------------------------------- /test/wiztk/net/address-info/test-address-info.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | 4 | #ifndef WIZTK_TEST_NET_ADDRESS_INFO_HPP_ 5 | #define WIZTK_TEST_NET_ADDRESS_INFO_HPP_ 6 | 7 | #include 8 | 9 | class TestAddressInfo : public testing::Test { 10 | 11 | public: 12 | 13 | TestAddressInfo() = default; 14 | 15 | ~TestAddressInfo() override = default; 16 | 17 | protected: 18 | 19 | void SetUp() final {} 20 | 21 | void TearDown() final {} 22 | 23 | }; 24 | 25 | #endif // WIZTK_TEST_NET_ADDRESS_INFO_HPP_ 26 | -------------------------------------------------------------------------------- /test/wiztk/net/ip-address/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources "*.cpp") 2 | file(GLOB headers "*.hpp") 3 | 4 | add_executable(net-ip-address ${sources} ${headers}) 5 | target_link_libraries(net-ip-address ${GTEST_LIBRARIES} wiztk-net) -------------------------------------------------------------------------------- /test/wiztk/net/ip-address/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include 6 | 7 | int main(int argc, char *argv[]) { 8 | testing::InitGoogleTest(&argc, argv); 9 | return RUN_ALL_TESTS(); 10 | } -------------------------------------------------------------------------------- /test/wiztk/net/ip-address/test-ip-address.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | 4 | #ifndef WIZTK_TEST_NET_IP_ADDRESS_HPP_ 5 | #define WIZTK_TEST_NET_IP_ADDRESS_HPP_ 6 | 7 | #include 8 | 9 | class TestIPAddress : public testing::Test { 10 | 11 | public: 12 | 13 | TestIPAddress() = default; 14 | 15 | ~TestIPAddress() override = default; 16 | 17 | protected: 18 | 19 | void SetUp() final {} 20 | 21 | void TearDown() final {} 22 | 23 | }; 24 | 25 | #endif // WIZTK_TEST_NET_IP_ADDRESS_HPP_ 26 | -------------------------------------------------------------------------------- /test/wiztk/net/server-socket/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources "*.cpp") 2 | file(GLOB headers "*.hpp") 3 | 4 | add_executable(net-server-socket ${sources} ${headers}) 5 | target_link_libraries(net-server-socket ${GTEST_LIBRARIES} wiztk-net) 6 | -------------------------------------------------------------------------------- /test/wiztk/net/server-socket/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include 6 | 7 | int main(int argc, char *argv[]) { 8 | testing::InitGoogleTest(&argc, argv); 9 | return RUN_ALL_TESTS(); 10 | } -------------------------------------------------------------------------------- /test/wiztk/net/server-socket/test-server-socket.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "test-server-socket.hpp" 3 | 4 | #include "wiztk/net/ip-address.hpp" 5 | #include "wiztk/net/server-socket.hpp" 6 | #include "wiztk/net/io-buffer.hpp" 7 | 8 | using namespace wiztk; 9 | using namespace wiztk::net; 10 | 11 | TEST_F(TestServerSocket, connect_1) { 12 | std::unique_ptr list = IPAddress::GetByHostAndService("127.0.0.1"); 13 | 14 | ServerSocket server = ServerSocket(kAddressFamilyINET, kSocketStream); 15 | std::cout << list->at(0)->ToString() << std::endl; 16 | server.Bind(*list->at(0)); 17 | 18 | server.Listen(50); 19 | 20 | size_t buffer_size = 512; 21 | 22 | IOBuffer buf(buffer_size); 23 | size_t size = 0; 24 | std::string echo = "echo"; 25 | while (true) { 26 | 27 | server.Accept(); 28 | 29 | size = server.Receive(buf, buffer_size); 30 | 31 | if (size == 0) { 32 | std::cout << buf.data() << std::endl; 33 | memcpy(buf.data(), echo.data(), echo.size()); 34 | size = server.Send(buf, buffer_size); 35 | break; 36 | } 37 | } 38 | 39 | server.Close(); 40 | 41 | ASSERT_TRUE(true); 42 | } 43 | -------------------------------------------------------------------------------- /test/wiztk/net/server-socket/test-server-socket.hpp: -------------------------------------------------------------------------------- 1 | // 2 | 3 | #ifndef WIZTK_TEST_NET_SERVER_SOCKET_HPP_ 4 | #define WIZTK_TEST_NET_SERVER_SOCKET_HPP_ 5 | 6 | #include 7 | 8 | class TestServerSocket : public testing::Test { 9 | 10 | public: 11 | 12 | TestServerSocket() = default; 13 | 14 | ~TestServerSocket() override = default; 15 | 16 | protected: 17 | 18 | void SetUp() final {} 19 | 20 | void TearDown() final {} 21 | 22 | }; 23 | 24 | #endif // WIZTK_TEST_NET_SERVER_SOCKET_HPP_ 25 | -------------------------------------------------------------------------------- /test/wiztk/net/socket/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources "*.cpp") 2 | file(GLOB headers "*.hpp") 3 | 4 | add_executable(net-socket ${sources} ${headers}) 5 | target_link_libraries(net-socket ${GTEST_LIBRARIES} wiztk-net) -------------------------------------------------------------------------------- /test/wiztk/net/socket/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include 6 | 7 | int main(int argc, char *argv[]) { 8 | testing::InitGoogleTest(&argc, argv); 9 | return RUN_ALL_TESTS(); 10 | } -------------------------------------------------------------------------------- /test/wiztk/net/socket/test-socket.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "test-socket.hpp" 3 | 4 | #include "wiztk/net/socket.hpp" 5 | #include "wiztk/net/ip-address.hpp" 6 | #include "wiztk/net/address-info.hpp" 7 | #include "wiztk/net/io-buffer.hpp" 8 | 9 | using namespace wiztk; 10 | using namespace wiztk::net; 11 | 12 | //TEST_F(TestSocket, connect_1) { 13 | // std::unique_ptr list = IPAddress::GetByHostAndService("www.baidu.com", "http"); 14 | // 15 | // Socket socket(kAddressFamilyINET, kSocketStream); 16 | // std::cout << list->at(0)->ToString() << std::endl; 17 | // 18 | // socket.Connect(*list->at(0)); 19 | // 20 | // IOBuffer buf(512); 21 | // std::string hello = "Hello There!"; 22 | // memcpy(buf.data(), hello.data(), hello.size()); 23 | // 24 | // size_t size = socket.Send(buf, 512); 25 | // if (size > 0) { 26 | // size = socket.Receive(buf, 512); 27 | // 28 | // std::cout << "buf received: " << size << std::endl; 29 | // } 30 | // 31 | // ASSERT_TRUE(true); 32 | //} 33 | 34 | TEST_F(TestSocket, get_address_family_1) { 35 | std::unique_ptr list = IPAddress::GetByHostAndService("www.baidu.com", "http"); 36 | 37 | ASSERT_TRUE(list->size() > 0); 38 | 39 | IPAddress *addr = list->at(0); 40 | 41 | Socket socket(kAddressFamilyINET, kSocketStream); 42 | AddressFamily af = addr->GetAddressFamily(); 43 | 44 | ASSERT_TRUE(af == kAddressFamilyINET); 45 | } 46 | -------------------------------------------------------------------------------- /test/wiztk/net/socket/test-socket.hpp: -------------------------------------------------------------------------------- 1 | // 2 | 3 | #ifndef WIZTK_TEST_NET_SOCKET_HPP_ 4 | #define WIZTK_TEST_NET_SOCKET_HPP_ 5 | 6 | #include 7 | 8 | class TestSocket : public testing::Test { 9 | 10 | public: 11 | 12 | TestSocket() = default; 13 | 14 | ~TestSocket() override = default; 15 | 16 | protected: 17 | 18 | void SetUp() final {} 19 | 20 | void TearDown() final {} 21 | 22 | }; 23 | 24 | #endif // WIZTK_TEST_NET_SOCKET_HPP_ 25 | -------------------------------------------------------------------------------- /test/wiztk/system/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The WizTK Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | add_subdirectory(time) 16 | add_subdirectory(threading) 17 | add_subdirectory(logging) -------------------------------------------------------------------------------- /test/wiztk/system/logging/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(logger) -------------------------------------------------------------------------------- /test/wiztk/system/logging/logger/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2017 - 2018 The WizTK Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | file(GLOB sources "*.cpp") 16 | file(GLOB headers "*.hpp") 17 | 18 | add_executable(system-logging-logger ${sources} ${headers}) 19 | target_link_libraries(system-logging-logger ${GTEST_LIBRARIES} wiztk-system) -------------------------------------------------------------------------------- /test/wiztk/system/logging/logger/main.cpp: -------------------------------------------------------------------------------- 1 | // file: main.cpp 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) { 6 | testing::InitGoogleTest(&argc, argv); 7 | return RUN_ALL_TESTS(); 8 | } -------------------------------------------------------------------------------- /test/wiztk/system/logging/logger/test-logger.cpp: -------------------------------------------------------------------------------- 1 | // 2 | 3 | #include "test-logger.hpp" 4 | 5 | #include "wiztk/system/logging/logger.hpp" 6 | #include "wiztk/system/logging/type.hpp" 7 | 8 | using namespace wiztk; 9 | using namespace wiztk::system; 10 | 11 | TEST_F(TestLogger, log_1) { 12 | logging::Logger::LogToSystem(logging::kNotice, "Hello World, this is PID %lu!", (unsigned long) getpid()); 13 | ASSERT_TRUE(true); 14 | } 15 | -------------------------------------------------------------------------------- /test/wiztk/system/logging/logger/test-logger.hpp: -------------------------------------------------------------------------------- 1 | // 2 | 3 | #ifndef WIZTK_TEST_SYSTEM_LOGGING_LOGGER_HPP_ 4 | #define WIZTK_TEST_SYSTEM_LOGGING_LOGGER_HPP_ 5 | 6 | #include 7 | 8 | class TestLogger : public testing::Test { 9 | 10 | public: 11 | 12 | TestLogger() = default; 13 | 14 | ~TestLogger() override = default; 15 | 16 | protected: 17 | 18 | void SetUp() final {} 19 | 20 | void TearDown() final {} 21 | 22 | }; 23 | 24 | #endif // WIZTK_TEST_SYSTEM_LOGGING_LOGGER_HPP_ 25 | -------------------------------------------------------------------------------- /test/wiztk/system/threading/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(thread) 2 | add_subdirectory(thread-local) -------------------------------------------------------------------------------- /test/wiztk/system/threading/thread-local/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2017 - 2018 The WizTK Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | file(GLOB sources "*.cpp") 16 | file(GLOB headers "*.hpp") 17 | 18 | add_executable(system-threading-thread-local ${sources} ${headers}) 19 | target_link_libraries(system-threading-thread-local ${GTEST_LIBRARIES} wiztk-system) 20 | -------------------------------------------------------------------------------- /test/wiztk/system/threading/thread-local/main.cpp: -------------------------------------------------------------------------------- 1 | // file: main.cpp 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) { 6 | testing::InitGoogleTest(&argc, argv); 7 | return RUN_ALL_TESTS(); 8 | } -------------------------------------------------------------------------------- /test/wiztk/system/threading/thread-local/test-thread-local.cpp: -------------------------------------------------------------------------------- 1 | // 2 | 3 | #include "test-thread-local.hpp" 4 | 5 | #include "wiztk/system/threading/thread.hpp" 6 | #include "wiztk/system/threading/thread-local.hpp" 7 | 8 | using namespace wiztk; 9 | using namespace wiztk::system; 10 | using namespace wiztk::system::threading; 11 | 12 | class MyThread : public threading::Thread { 13 | 14 | public: 15 | 16 | explicit MyThread(ThreadLocal *local) 17 | : Thread(), local_(local) {} 18 | 19 | ~MyThread() final = default; 20 | 21 | protected: 22 | 23 | void Run() final { 24 | local_->Set(&kCount); 25 | for (int i = 0; i < 10; ++i) { 26 | sleep(1); 27 | std::cout << "num: " << kCount << std::endl; 28 | kCount++; 29 | } 30 | } 31 | 32 | private: 33 | 34 | ThreadLocal *local_ = nullptr; 35 | 36 | static int kCount; 37 | 38 | }; 39 | 40 | int MyThread::kCount = 0; 41 | 42 | TEST_F(TestThreadLocal, initial_1) { 43 | ThreadLocal mylocal; 44 | 45 | ASSERT_TRUE(mylocal.Get() == nullptr); 46 | } 47 | 48 | TEST_F(TestThreadLocal, construct_1) { 49 | ThreadLocal mylocal; 50 | 51 | int value = 0; 52 | mylocal.Set(&value); 53 | value++; 54 | 55 | MyThread thread(&mylocal); 56 | thread.Start(); 57 | thread.Join(); 58 | 59 | int *d = mylocal.Get(); 60 | 61 | ASSERT_TRUE(*d == 1); 62 | } 63 | -------------------------------------------------------------------------------- /test/wiztk/system/threading/thread-local/test-thread-local.hpp: -------------------------------------------------------------------------------- 1 | // 2 | 3 | #ifndef WIZTK_TEST_SYSTEM_THREADING_THREAD_LOCAL_HPP_ 4 | #define WIZTK_TEST_SYSTEM_THREADING_THREAD_LOCAL_HPP_ 5 | 6 | #include 7 | 8 | class TestThreadLocal : public testing::Test { 9 | 10 | public: 11 | 12 | TestThreadLocal() = default; 13 | 14 | ~TestThreadLocal() override = default; 15 | 16 | protected: 17 | 18 | void SetUp() final {} 19 | 20 | void TearDown() final {} 21 | 22 | }; 23 | 24 | #endif // WIZTK_TEST_SYSTEM_THREADING_THREAD_LOCAL_HPP_ 25 | -------------------------------------------------------------------------------- /test/wiztk/system/threading/thread/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2017 - 2018 The WizTK Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | file(GLOB sources "*.cpp") 16 | file(GLOB headers "*.hpp") 17 | 18 | add_executable(system-threading-thread ${sources} ${headers}) 19 | target_link_libraries(system-threading-thread ${GTEST_LIBRARIES} wiztk-system) 20 | -------------------------------------------------------------------------------- /test/wiztk/system/threading/thread/main.cpp: -------------------------------------------------------------------------------- 1 | // file: main.cpp 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) { 6 | testing::InitGoogleTest(&argc, argv); 7 | return RUN_ALL_TESTS(); 8 | } -------------------------------------------------------------------------------- /test/wiztk/system/threading/thread/test-thread.hpp: -------------------------------------------------------------------------------- 1 | // 2 | 3 | #ifndef WIZTK_TEST_SYSTEM_THREADING_THREAD_HPP_ 4 | #define WIZTK_TEST_SYSTEM_THREADING_THREAD_HPP_ 5 | 6 | #include 7 | 8 | class TestThread : public testing::Test { 9 | 10 | public: 11 | 12 | TestThread() = default; 13 | 14 | ~TestThread() override = default; 15 | 16 | protected: 17 | 18 | void SetUp() final {} 19 | 20 | void TearDown() final {} 21 | 22 | }; 23 | 24 | #endif // WIZTK_TEST_SYSTEM_THREADING_THREAD_HPP_ 25 | -------------------------------------------------------------------------------- /test/wiztk/system/time/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The WizTK Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | add_subdirectory(clock) 16 | add_subdirectory(timer) -------------------------------------------------------------------------------- /test/wiztk/system/time/clock/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2017 - 2018 The WizTK Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | file(GLOB sources "*.cpp") 16 | file(GLOB headers "*.hpp") 17 | 18 | add_executable(system-time-clock ${sources} ${headers}) 19 | target_link_libraries(system-time-clock ${GTEST_LIBRARIES} wiztk-system) -------------------------------------------------------------------------------- /test/wiztk/system/time/clock/main.cpp: -------------------------------------------------------------------------------- 1 | // file: main.cpp 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) { 6 | testing::InitGoogleTest(&argc, argv); 7 | return RUN_ALL_TESTS(); 8 | } -------------------------------------------------------------------------------- /test/wiztk/system/time/clock/test-clock.cpp: -------------------------------------------------------------------------------- 1 | // 2 | 3 | #include "test-clock.hpp" 4 | 5 | #include "wiztk/system/time/realtime-clock.hpp" 6 | 7 | #include 8 | 9 | using namespace wiztk; 10 | using namespace wiztk::system; 11 | 12 | TEST_F(TestClock, construct_1) { 13 | time::RealtimeClock clock(2017, 11, 28, 10, 30); 14 | std::string str = clock.ToString(); 15 | 16 | std::cout << str << std::endl; 17 | 18 | ASSERT_TRUE(true); 19 | } 20 | 21 | TEST_F(TestClock, now_1) { 22 | time::RealtimeClock time = time::RealtimeClock::Now(); 23 | std::string str = time.ToString(); 24 | 25 | std::cout << str << std::endl; 26 | 27 | ASSERT_TRUE(true); 28 | } 29 | -------------------------------------------------------------------------------- /test/wiztk/system/time/clock/test-clock.hpp: -------------------------------------------------------------------------------- 1 | // 2 | 3 | #ifndef WIZTK_TEST_SYSTEM_TIME_CLOCK_HPP_ 4 | #define WIZTK_TEST_SYSTEM_TIME_CLOCK_HPP_ 5 | 6 | #include 7 | 8 | class TestClock : public testing::Test { 9 | 10 | public: 11 | 12 | TestClock() = default; 13 | 14 | ~TestClock() override = default; 15 | 16 | protected: 17 | 18 | void SetUp() final {} 19 | 20 | void TearDown() final {} 21 | 22 | }; 23 | 24 | #endif // WIZTK_TEST_SYSTEM_TIME_CLOCK_HPP_ 25 | -------------------------------------------------------------------------------- /test/wiztk/system/time/timer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2017 - 2018 The WizTK Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | file(GLOB sources "*.cpp") 16 | file(GLOB headers "*.hpp") 17 | 18 | add_executable(system-time-timer ${sources} ${headers}) 19 | target_link_libraries(system-time-timer ${GTEST_LIBRARIES} wiztk-system) -------------------------------------------------------------------------------- /test/wiztk/system/time/timer/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #include 6 | 7 | int main(int argc, char *argv[]) { 8 | testing::InitGoogleTest(&argc, argv); 9 | return RUN_ALL_TESTS(); 10 | } -------------------------------------------------------------------------------- /test/wiztk/system/time/timer/test-timer.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zhanggyb on 16-9-19. 3 | // 4 | 5 | #ifndef WIZTK_TEST_SYSTEM_TIME_TIMER_HPP_ 6 | #define WIZTK_TEST_SYSTEM_TIME_TIMER_HPP_ 7 | 8 | #include 9 | 10 | class TestTimer : public testing::Test { 11 | 12 | public: 13 | 14 | TestTimer() = default; 15 | 16 | ~TestTimer() override = default; 17 | 18 | protected: 19 | 20 | void SetUp() final {} 21 | 22 | void TearDown() final {} 23 | 24 | }; 25 | 26 | #endif // WIZTK_TEST_SYSTEM_TIME_TIMER_HPP_ 27 | --------------------------------------------------------------------------------