Skip to content

Commit

Permalink
Save and restore webbrowsers [DISCL-6] (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphael Dumusc authored Oct 28, 2016
1 parent a4de5a1 commit f14df6e
Show file tree
Hide file tree
Showing 72 changed files with 1,192 additions and 612 deletions.
2 changes: 1 addition & 1 deletion .gitexternals
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# -*- mode: cmake -*-
# CMake/common https://github.com/Eyescale/CMake.git ca64fd0
# CMake/common https://github.com/Eyescale/CMake.git 009f72c
15 changes: 5 additions & 10 deletions CMake/GitExternal.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -281,13 +281,10 @@ if(EXISTS ${GIT_EXTERNALS} AND NOT GIT_EXTERNAL_SCRIPT_MODE)
if(NOT TARGET update)
add_custom_target(update)
endif()
if(NOT TARGET update-gitexternal)
add_custom_target(update-gitexternal)
add_custom_target(flatten-gitexternal)
add_dependencies(update update-gitexternal)
endif()
if(NOT TARGET ${PROJECT_NAME}-flatten-gitexternal)
if(NOT TARGET ${PROJECT_NAME}-update-gitexternal)
add_custom_target(${PROJECT_NAME}-update-gitexternal)
add_custom_target(${PROJECT_NAME}-flatten-gitexternal)
add_dependencies(update ${PROJECT_NAME}-update-gitexternal)
endif()

# Create a unique, flat name
Expand Down Expand Up @@ -328,7 +325,7 @@ endif()")
COMMENT "Update ${REPO} in ${GIT_EXTERNALS_BASE}"
DEPENDS ${GIT_EXTERNAL_TARGET}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
add_dependencies(update-gitexternal
add_dependencies(${PROJECT_NAME}-update-gitexternal
update-gitexternal-${GIT_EXTERNAL_NAME})

# Flattens a git external repository into its parent repo:
Expand All @@ -346,12 +343,10 @@ endif()")
COMMENT "Flatten ${REPO} into ${DIR}"
DEPENDS ${PROJECT_NAME}-make-branch
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${DIR}")
add_dependencies(flatten-gitexternal
flatten-gitexternal-${GIT_EXTERNAL_NAME})
add_dependencies(${PROJECT_NAME}-flatten-gitexternal
flatten-gitexternal-${GIT_EXTERNAL_NAME})

foreach(_target flatten-gitexternal-${GIT_EXTERNAL_NAME} ${PROJECT_NAME}-flatten-gitexternal flatten-gitexternal update-gitexternal-${GIT_EXTERNAL_NAME} ${GIT_EXTERNAL_TARGET} update-gitexternal update)
foreach(_target flatten-gitexternal-${GIT_EXTERNAL_NAME} ${PROJECT_NAME}-flatten-gitexternal update-gitexternal-${GIT_EXTERNAL_NAME} ${GIT_EXTERNAL_TARGET} ${PROJECT_NAME}-update-gitexternal update)
set_target_properties(${_target} PROPERTIES
EXCLUDE_FROM_DEFAULT_BUILD ON FOLDER git)
endforeach()
Expand Down
4 changes: 2 additions & 2 deletions apps/Launcher/Launcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ Launcher::Launcher( int& argc, char* argv[] )
const CommandLineOptions options( argc, argv );
const MasterConfiguration config( options.getConfiguration( ));

const auto deflectStreamname = options.getStreamname().toStdString();
const auto deflectStreamId = options.getStreamId().toStdString();
_qmlStreamer.reset( new deflect::qt::QmlStreamer( deflectQmlFile,
deflectHost,
deflectStreamname ));
deflectStreamId ));

connect( _qmlStreamer.get(), &deflect::qt::QmlStreamer::streamClosed,
this, &QCoreApplication::quit );
Expand Down
2 changes: 1 addition & 1 deletion apps/LocalStreamer/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ bool Application::initialize( const CommandLineOptions& options )
this, &Application::sendData );

// Connect to Tide
_deflectStream = new deflect::Stream( options.getStreamname().toStdString(),
_deflectStream = new deflect::Stream( options.getStreamId().toStdString(),
TIDE_STREAM_HOST_ADDRESS );
if( !_deflectStream->isConnected( ))
{
Expand Down
9 changes: 6 additions & 3 deletions apps/Webbrowser/Webbrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ Webbrowser::Webbrowser( int& argc, char* argv[] )
{
const CommandLineOptions options( argc, argv );

const auto deflectStreamname = options.getStreamname().toStdString();
const auto deflectStreamId = options.getStreamId().toStdString();
_qmlStreamer.reset( new deflect::qt::QmlStreamer( deflectQmlFile,
deflectHost,
deflectStreamname ));
deflectStreamId ));

connect( _qmlStreamer.get(), &deflect::qt::QmlStreamer::streamClosed,
this, &QCoreApplication::quit );
Expand All @@ -90,6 +90,7 @@ Webbrowser::Webbrowser( int& argc, char* argv[] )
_webengine->setProperty( "url", options.getUrl( ));

connect( _webengine, SIGNAL( urlChanged( )), this, SLOT( _sendData( )));
connect( _webengine, SIGNAL( titleChanged( )), this, SLOT( _sendData( )));
}

Webbrowser::~Webbrowser() {}
Expand Down Expand Up @@ -151,8 +152,10 @@ WebbrowserHistory _getNavigationHistory( const QQuickItem* webengine )
void Webbrowser::_sendData()
{
const auto history = _getNavigationHistory( _webengine );
const auto title = QQmlProperty::read( _webengine, "title" ).toString();
const auto restPort = 0; // no rest interface
const auto data = WebbrowserContent::serializeData( history, restPort );
const auto data = WebbrowserContent::serializeData( history, title,
restPort );
if( !_qmlStreamer->sendData( data ))
QGuiApplication::quit();
}
4 changes: 2 additions & 2 deletions apps/Whiteboard/Whiteboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ Whiteboard::Whiteboard( int& argc, char* argv[] )
const CommandLineOptions options( argc, argv );
const MasterConfiguration config( options.getConfiguration( ));

const auto deflectStreamname = options.getStreamname().toStdString();
const auto deflectStreamId = options.getStreamId().toStdString();
_qmlStreamer.reset( new deflect::qt::QmlStreamer( deflectQmlFile,
deflectHost,
deflectStreamname ));
deflectStreamId ));

connect( _qmlStreamer.get(), &deflect::qt::QmlStreamer::streamClosed,
this, &QCoreApplication::quit );
Expand Down
3 changes: 3 additions & 0 deletions doc/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Changelog {#changelog}

# Release 1.2 (git master)

* [97](https://github.com/BlueBrain/Tide/pull/97):
Webbrowsers can be saved and restored from sessions and display the page title
in their title bar.
* [95](https://github.com/BlueBrain/Tide/pull/95):
More consistent and intuitive user experience:
- Double-tap a window to make it fullscreen
Expand Down
8 changes: 5 additions & 3 deletions tests/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,17 @@ else()
)
endif()

if(NOT TARGET Qt5::WebEngine AND X11_FOUND AND TARGET Qt5::WebKitWidgets)
if(X11_FOUND AND TARGET Qt5::WebKitWidgets)
list(APPEND TEST_LIBRARIES ${X11_LIBRARIES} Qt5::WebKitWidgets)
else()
list(APPEND EXCLUDE_FROM_TESTS
core/LocalPixelStreamerTests.cpp
core/WebbrowserTests.cpp
core/WebbrowserContentTests.cpp
core/WebkitTests.cpp
core/WebkitHtmlSelectReplacementTests.cpp)
endif()
if(NOT TARGET Qt5::WebEngine AND NOT TARGET Qt5::WebKitWidgets)
list(APPEND EXCLUDE_FROM_TESTS core/WebbrowserContentTests.cpp)
endif()

# Recursively compile unit tests for *.cpp files in the current folder,
# linking with TEST_LIBRARIES and excluding EXCLUDE_FROM_TESTS
Expand Down
8 changes: 4 additions & 4 deletions tests/cpp/core/CommandLineOptionsTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ BOOST_AUTO_TEST_CASE( testCommandLineDefaults )
CommandLineOptions options;

BOOST_CHECK( !options.getHelp() );
BOOST_CHECK_EQUAL( options.getStreamname().toStdString(), "" );
BOOST_CHECK_EQUAL( options.getStreamId().toStdString(), "" );
BOOST_CHECK_EQUAL( options.getPixelStreamerType(), PS_UNKNOWN );
BOOST_CHECK_EQUAL( options.getUrl().toStdString(), "" );
BOOST_CHECK_EQUAL( options.getConfiguration().toStdString(), "" );
Expand All @@ -67,7 +67,7 @@ BOOST_AUTO_TEST_CASE( testCommandLineDefaults )
void setOptionParameters( CommandLineOptions& options )
{
options.setHelp( true );
options.setStreamname( "MyStreamer" );
options.setStreamId( "MyStreamer" );
options.setPixelStreamerType( PS_WEBKIT );
options.setUrl( "http://www.perdu.com" );
options.setHeight( 640 );
Expand All @@ -78,7 +78,7 @@ void setOptionParameters( CommandLineOptions& options )
void checkOptionParameters( const CommandLineOptions& options )
{
BOOST_CHECK( options.getHelp() );
BOOST_CHECK_EQUAL( options.getStreamname().toStdString(), "MyStreamer" );
BOOST_CHECK_EQUAL( options.getStreamId().toStdString(), "MyStreamer" );
BOOST_CHECK_EQUAL( options.getPixelStreamerType(), PS_WEBKIT );
BOOST_CHECK_EQUAL( options.getUrl().toStdString(), "http://www.perdu.com" );
BOOST_CHECK_EQUAL( options.getHeight(), 640 );
Expand All @@ -88,7 +88,7 @@ void checkOptionParameters( const CommandLineOptions& options )

BOOST_CHECK_EQUAL( options.getCommandLine().toStdString(),
"--type webkit --width 480 --height 640 --help "
"--streamname MyStreamer --url http://www.perdu.com "
"--streamid MyStreamer --url http://www.perdu.com "
"--config /path/to/configuration.xml" );
}

Expand Down
7 changes: 6 additions & 1 deletion tests/cpp/core/ContentControllerTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
#if TIDE_ENABLE_PDF_SUPPORT
# include "control/PDFController.h"
#endif
#if TIDE_USE_QT5WEBKITWIDGETS || TIDE_USE_QT5WEBENGINE
#include "control/PixelStreamController.h"
#if TIDE_USE_QT5WEBKITWIDGETS
# include "control/WebbrowserController.h"
#endif
#include "control/ZoomController.h"
Expand Down Expand Up @@ -98,7 +99,11 @@ BOOST_AUTO_TEST_CASE( testFactoryMethod )
std::bad_cast );
ContentWindow webWindow( ContentFactory::getWebbrowserContent( "abc" ));
BOOST_CHECK_NO_THROW( controller = ContentController::create( webWindow ));
#endif
#if TIDE_USE_QT5WEBKITWIDGETS
BOOST_CHECK( dynamic_cast<WebbrowserController*>( controller.get( )));
#elif TIDE_USE_QT5WEBENGINE
BOOST_CHECK( dynamic_cast<PixelStreamController*>( controller.get( )));
#endif

#if TIDE_ENABLE_PDF_SUPPORT
Expand Down
2 changes: 0 additions & 2 deletions tests/cpp/core/ContentWindowControllerTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
#define BOOST_TEST_MODULE ContentWindowControllerTests
#include <boost/test/unit_test.hpp>

#include <boost/make_shared.hpp>

#include "control/ContentWindowController.h"
#include "control/LayoutEngine.h"
#include "scene/ContentWindow.h"
Expand Down
2 changes: 0 additions & 2 deletions tests/cpp/core/DisplayGroupTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@

#include "DummyContent.h"

#include <boost/make_shared.hpp>

namespace
{
const QSize wallSize( 1000, 1000 );
Expand Down
2 changes: 0 additions & 2 deletions tests/cpp/core/JsonOptionsTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
#include "rest/JsonOptions.h"
#include "scene/Options.h"

#include <boost/make_shared.hpp>

namespace
{
const std::string defaultJson{
Expand Down
1 change: 0 additions & 1 deletion tests/cpp/core/LoggingUtilityTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@

#define BOOST_TEST_MODULE LoggingUtilityTest

#include <boost/make_shared.hpp>
#include <boost/test/unit_test.hpp>

#include "LoggingUtility.h"
Expand Down
42 changes: 21 additions & 21 deletions tests/cpp/core/PixelStreamWindowManagerTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,25 +98,25 @@ BOOST_AUTO_TEST_CASE( testNoStreamerWindowCreation )
const QSize size( testWindowSize );

windowManager.openWindow( uri, pos, size );
ContentWindowPtr window = windowManager.getContentWindow( uri );
ContentWindowPtr window = windowManager.getWindow( uri );
BOOST_REQUIRE( window );

BOOST_CHECK_EQUAL( window, windowManager.getContentWindow( uri ));
BOOST_CHECK_EQUAL( window, windowManager.getWindow( uri ));

const QRectF& coords = window->getCoordinates();
BOOST_CHECK_EQUAL( coords.center(), pos );
BOOST_CHECK_EQUAL( coords.size(), size );

windowManager.closePixelStreamWindow( uri );
BOOST_CHECK( !windowManager.getContentWindow( uri ));
windowManager.handleStreamEnd( uri );
BOOST_CHECK( !windowManager.getWindow( uri ));
}

BOOST_AUTO_TEST_CASE( testEventReceiver )
{
DisplayGroupPtr displayGroup( new DisplayGroup( wallSize ));
PixelStreamWindowManager windowManager( *displayGroup );
windowManager.openWindow( CONTENT_URI, testWindowPos, testWindowSize );
ContentWindowPtr window = windowManager.getContentWindow( CONTENT_URI );
ContentWindowPtr window = windowManager.getWindow( CONTENT_URI );
BOOST_REQUIRE( window );

auto content = dynamic_cast<PixelStreamContent*>( window->getContentPtr( ));
Expand Down Expand Up @@ -168,15 +168,15 @@ BOOST_AUTO_TEST_CASE( testExplicitWindowCreation )
const QSize size( testWindowSize );

windowManager.openWindow( uri, pos, size );
ContentWindowPtr window = windowManager.getContentWindow( uri );
ContentWindowPtr window = windowManager.getWindow( uri );
BOOST_REQUIRE( window );

BOOST_CHECK_EQUAL( window, windowManager.getContentWindow( uri ));
BOOST_CHECK_EQUAL( window, windowManager.getWindow( uri ));
BOOST_CHECK_EQUAL( window,
displayGroup->getContentWindow( window->getID( )));

windowManager.openPixelStreamWindow( uri );
BOOST_CHECK_EQUAL( window, windowManager.getContentWindow( uri ));
windowManager.handleStreamStart( uri );
BOOST_CHECK_EQUAL( window, windowManager.getWindow( uri ));

ContentPtr content = window->getContent();
BOOST_REQUIRE( content );
Expand All @@ -193,8 +193,8 @@ BOOST_AUTO_TEST_CASE( testExplicitWindowCreation )
BOOST_CHECK_EQUAL( coords.center(), pos );
BOOST_CHECK_EQUAL( coords.size(), size );

windowManager.closePixelStreamWindow( uri );
BOOST_CHECK( !windowManager.getContentWindow( uri ));
windowManager.handleStreamEnd( uri );
BOOST_CHECK( !windowManager.getWindow( uri ));
BOOST_CHECK( !displayGroup->getContentWindow( window->getID( )));
}

Expand All @@ -208,8 +208,8 @@ BOOST_AUTO_TEST_CASE( testImplicitWindowCreation )
const QPointF pos( wallSize.width() * 0.5, wallSize.height() * 0.5 );
const QSize size( defaultPixelStreamWindowSize );

windowManager.openPixelStreamWindow( uri );
ContentWindowPtr window = windowManager.getContentWindow( uri );
windowManager.handleStreamStart( uri );
ContentWindowPtr window = windowManager.getWindow( uri );
BOOST_REQUIRE( window );
BOOST_CHECK_EQUAL( window,
displayGroup->getContentWindow( window->getID( )));
Expand All @@ -236,8 +236,8 @@ BOOST_AUTO_TEST_CASE( testImplicitWindowCreation )
BOOST_CHECK_EQUAL( coords.center(), pos );
BOOST_CHECK_EQUAL( coords.size(), testFrameSize );

windowManager.closePixelStreamWindow( uri );
BOOST_CHECK( !windowManager.getContentWindow( uri ));
windowManager.handleStreamEnd( uri );
BOOST_CHECK( !windowManager.getWindow( uri ));
BOOST_CHECK( !displayGroup->getContentWindow( window->getID( )));
}

Expand All @@ -246,8 +246,8 @@ BOOST_AUTO_TEST_CASE( testSizeHints )
DisplayGroupPtr displayGroup( new DisplayGroup( wallSize ));
PixelStreamWindowManager windowManager( *displayGroup );
const QString uri = CONTENT_URI;
windowManager.openPixelStreamWindow( uri );
ContentWindowPtr window = windowManager.getContentWindow( uri );
windowManager.handleStreamStart( uri );
ContentWindowPtr window = windowManager.getWindow( uri );
ContentPtr content = window->getContent();

BOOST_CHECK_EQUAL( content->getDimensions(), QSizeF( ));
Expand Down Expand Up @@ -279,8 +279,8 @@ BOOST_AUTO_TEST_CASE( hideAndShowWindow )
PixelStreamWindowManager windowManager( *displayGroup );

const QString uri = CONTENT_URI;
windowManager.openPixelStreamWindow( uri );
ContentWindowPtr window = windowManager.getContentWindow( uri );
windowManager.handleStreamStart( uri );
ContentWindowPtr window = windowManager.getWindow( uri );

BOOST_REQUIRE( !window->isHidden( ));
BOOST_REQUIRE( !window->isPanel( ));
Expand All @@ -298,8 +298,8 @@ BOOST_AUTO_TEST_CASE( hideAndShowPanel )
PixelStreamWindowManager windowManager( *displayGroup );

const QString uri = PANEL_URI;
windowManager.openPixelStreamWindow( uri );
ContentWindowPtr panel = windowManager.getContentWindow( uri );
windowManager.handleStreamStart( uri );
ContentWindowPtr panel = windowManager.getWindow( uri );

BOOST_REQUIRE( panel->isPanel( ));
BOOST_REQUIRE( !panel->isHidden( ));
Expand Down
2 changes: 0 additions & 2 deletions tests/cpp/core/VisibilityHelperTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@

#include "DummyContent.h"

#include <boost/make_shared.hpp>

namespace
{
const QSize groupSize( 800, 600 );
Expand Down
Loading

0 comments on commit f14df6e

Please sign in to comment.