Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added simple test with view involved
  • Loading branch information
tmeshkova committed Oct 16, 2014
1 parent 583567c commit 201dbc7
Show file tree
Hide file tree
Showing 10 changed files with 183 additions and 6 deletions.
2 changes: 1 addition & 1 deletion embedding/embedlite/tests/moz.build
Expand Up @@ -3,7 +3,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

DIRS += ['qtasync']
DIRS += ['shared', 'qtcoreasync', 'qtviewasync']

SimplePrograms([
'embedLiteCoreInitTest',
Expand Down
Expand Up @@ -6,21 +6,21 @@

Program('embedLiteCoreInitTestAsync')

GENERATED_SOURCES += [
'moc_qmessagepump.cpp',
]

SOURCES += [
'embedLiteCoreInitTestAsync.cpp',
'qmessagepump.cpp',
]

DEFINES['XPCOM_GLUE'] = True
DISABLE_STL_WRAPPING = True

USE_LIBS += [
'qmessagepump',
'xpcomglue',
]

LOCAL_INCLUDES += [
'../shared',
]

OS_LIBS += CONFIG['TK_LIBS']
CXXFLAGS += CONFIG['TK_CFLAGS']
16 changes: 16 additions & 0 deletions embedding/embedlite/tests/qtviewasync/Makefile.in
@@ -0,0 +1,16 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

DEPTH = @DEPTH@
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = @relativesrcdir@

include $(DEPTH)/config/autoconf.mk

NSDISTMODE = copy

include $(topsrcdir)/config/config.mk
include $(topsrcdir)/config/rules.mk
104 changes: 104 additions & 0 deletions embedding/embedlite/tests/qtviewasync/embedLiteViewInitTestAsync.cpp
@@ -0,0 +1,104 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "mozilla/embedlite/EmbedInitGlue.h"
#include "mozilla/embedlite/EmbedLiteApp.h"
#include "mozilla/embedlite/EmbedLiteView.h"
#include "qmessagepump.h"

#ifdef MOZ_WIDGET_QT
#include <QGuiApplication>
#endif

using namespace mozilla::embedlite;

class MyListener : public EmbedLiteAppListener, public EmbedLiteViewListener
{
public:
MyListener(EmbedLiteApp* aApp) : mApp(aApp), mView(NULL) {
}
virtual ~MyListener() { }
virtual void Initialized() {
printf("Embedding initialized, let's make view");
mView = mApp->CreateView();
mView->SetListener(this);
}
virtual void ViewInitialized() {
printf("Embedding has created view:%p, Yay\n", mView);
// FIXME if resize is not called,
// then Widget/View not initialized properly and prevent destroy process
mView->SetViewSize(800, 600);
mView->LoadURL("data:text/html,<body bgcolor=red>TestApp</body>");
}
virtual void Destroyed() {
printf("Embedding destroyed\n");
qApp->quit();
}
virtual void ViewDestroyed() {
printf("OnViewDestroyed\n");
}
virtual void OnLocationChanged(const char* aLocation, bool aCanGoBack, bool aCanGoForward) {
printf("OnLocationChanged: loc:%s, canBack:%i, canForw:%i\n", aLocation, aCanGoBack, aCanGoForward);
}
virtual void OnLoadStarted(const char* aLocation) {
printf("OnLoadStarted: loc:%s\n", aLocation);
}
virtual void OnLoadFinished(void) {
printf("OnLoadFinished\n");
}
virtual void OnLoadRedirect(void) {
printf("OnLoadRedirect\n");
}
virtual void OnLoadProgress(int32_t aProgress, int32_t aCurTotal, int32_t aMaxTotal) {
printf("OnLoadProgress: progress:%i curT:%i, maxT:%i\n", aProgress, aCurTotal, aMaxTotal);
}
virtual void OnSecurityChanged(const char* aStatus, unsigned int aState) {
printf("OnSecurityChanged: status:%s, stat:%u\n", aStatus, aState);
}
virtual void OnFirstPaint(int32_t aX, int32_t aY) {
printf("OnFirstPaint pos[%i,%i]\n", aX, aY);
}
virtual void OnScrolledAreaChanged(unsigned int aWidth, unsigned int aHeight) {
printf("OnScrolledAreaChanged: sz[%u,%u]\n", aWidth, aHeight);
}
virtual void OnScrollChanged(int32_t offSetX, int32_t offSetY) {
printf("OnScrollChanged: scroll:%i,%i\n", offSetX, offSetY);
}
virtual void OnObserve(const char* aTopic, const char16_t* aData) {
printf("OnObserve: top:%s, data:%s\n", aTopic, NS_ConvertUTF16toUTF8(aData).get());
}

private:
EmbedLiteApp* mApp;
EmbedLiteView* mView;
};

int main(int argc, char** argv)
{
#ifdef MOZ_WIDGET_QT
QGuiApplication app(argc, argv);
#endif

printf("Load XUL Symbols\n");
if (LoadEmbedLite(argc, argv)) {
printf("XUL Symbols loaded\n");
EmbedLiteApp* mapp = XRE_GetEmbedLite();
MyListener* listener = new MyListener(mapp);
mapp->SetListener(listener);
MessagePumpQt* mQtPump = new MessagePumpQt(mapp);
bool res = mapp->StartWithCustomPump(EmbedLiteApp::EMBED_THREAD, mQtPump->EmbedLoop());
printf("XUL Symbols loaded: init res:%i\n", res);
app.exec();
delete mQtPump;
printf("Execution stopped\n");
delete listener;
printf("Listener destroyed\n");
delete mapp;
printf("App destroyed\n");
} else {
printf("XUL Symbols failed to load\n");
}
return 0;
}
26 changes: 26 additions & 0 deletions embedding/embedlite/tests/qtviewasync/moz.build
@@ -0,0 +1,26 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Program('embedLiteViewInitTestAsync')

SOURCES += [
'embedLiteViewInitTestAsync.cpp',
]

DEFINES['XPCOM_GLUE'] = True
DISABLE_STL_WRAPPING = True

USE_LIBS += [
'qmessagepump',
'xpcomglue',
]

LOCAL_INCLUDES += [
'../shared',
]

OS_LIBS += CONFIG['TK_LIBS']
CXXFLAGS += CONFIG['TK_CFLAGS']
31 changes: 31 additions & 0 deletions embedding/embedlite/tests/shared/moz.build
@@ -0,0 +1,31 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

USE_STATIC_LIBS = True

GENERATED_SOURCES += [
'moc_qmessagepump.cpp',
]

EXPORTS += [
'qmessagepump.h',
]

SOURCES += [
'qmessagepump.cpp',
]

Library('qmessagepump')

DEFINES['XPCOM_GLUE'] = True
DISABLE_STL_WRAPPING = True

USE_LIBS += [
'xpcomglue',
]

OS_LIBS += CONFIG['TK_LIBS']
CXXFLAGS += CONFIG['TK_CFLAGS']

0 comments on commit 201dbc7

Please sign in to comment.