mirror of https://github.com/ethereum/go-ethereum
Added timeout for filter & removed clipboard. Closes #350
parent
0006585391
commit
982f73fa6d
@ -0,0 +1,37 @@ |
||||
package rpc |
||||
|
||||
import ( |
||||
"sync" |
||||
"testing" |
||||
"time" |
||||
) |
||||
|
||||
func TestFilterClose(t *testing.T) { |
||||
api := &EthereumApi{ |
||||
logs: make(map[int]*logFilter), |
||||
messages: make(map[int]*whisperFilter), |
||||
quit: make(chan struct{}), |
||||
} |
||||
|
||||
filterTickerTime = 1 |
||||
api.logs[0] = &logFilter{} |
||||
api.messages[0] = &whisperFilter{} |
||||
var wg sync.WaitGroup |
||||
wg.Add(1) |
||||
go api.start() |
||||
go func() { |
||||
select { |
||||
case <-time.After(500 * time.Millisecond): |
||||
api.stop() |
||||
wg.Done() |
||||
} |
||||
}() |
||||
wg.Wait() |
||||
if len(api.logs) != 0 { |
||||
t.Error("expected logs to be empty") |
||||
} |
||||
|
||||
if len(api.messages) != 0 { |
||||
t.Error("expected messages to be empty") |
||||
} |
||||
} |
@ -1,11 +0,0 @@ |
||||
#pragma once |
||||
|
||||
#include "clipboard.hpp" |
||||
|
||||
typedef void Clipboard_; |
||||
|
||||
Clipboard_ *initClipboard() |
||||
{ |
||||
Clipboard *clipboard = new(Clipboard); |
||||
return static_cast<Clipboard_*>(clipboard); |
||||
} |
@ -1,20 +0,0 @@ |
||||
#include "clipboard.h" |
||||
|
||||
#include <QClipboard> |
||||
|
||||
Clipboard::Clipboard() |
||||
{ |
||||
connect(QApplication::clipboard(), &QClipboard::dataChanged, [this] { emit clipboardChanged();}); |
||||
} |
||||
|
||||
QString Clipboard::get() const |
||||
{ |
||||
QClipboard *clipboard = QApplication::clipboard(); |
||||
return clipboard->text(); |
||||
} |
||||
|
||||
void Clipboard::toClipboard(QString _text) |
||||
{ |
||||
QClipboard *clipboard = QApplicationion::clipboard(); |
||||
clipboard->setText(_text); |
||||
} |
@ -1,15 +0,0 @@ |
||||
package clipboard |
||||
|
||||
// #cgo CPPFLAGS: -I./
|
||||
// #cgo CXXFLAGS: -std=c++0x -pedantic-errors -Wall -fno-strict-aliasing
|
||||
// #cgo LDFLAGS: -lstdc++
|
||||
// #cgo pkg-config: Qt5Quick
|
||||
//
|
||||
// #include "capi.hpp"
|
||||
import "C" |
||||
|
||||
import "github.com/obscuren/qml" |
||||
|
||||
func SetQMLClipboard(context *qml.Context) { |
||||
context.SetVar("clipboard", (unsafe.Pointer)(C.initClipboard())) |
||||
} |
@ -1,23 +0,0 @@ |
||||
#pragma once |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
class Clipboard : public QObject |
||||
{ |
||||
Q_OBJECT |
||||
Q_PROPERTY(QString get READ get WRITE toClipboard NOTIFY clipboardChanged) |
||||
public: |
||||
Clipboard(); |
||||
virtual ~Clipboard(){} |
||||
|
||||
Q_INVOKABLE void toClipboard(QString _text); |
||||
|
||||
signals: |
||||
void clipboardChanged(); |
||||
}; |
||||
|
||||
#ifdef __cplusplus |
||||
} // extern "C"
|
||||
#endif |
Loading…
Reference in new issue