Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Added simple test with view involved
- Loading branch information
Showing
10 changed files
with
183 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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
104
embedding/embedlite/tests/qtviewasync/embedLiteViewInitTestAsync.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'] |
File renamed without changes.
File renamed without changes.