зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1194112. Part 6 - add a test case to test the exclusive mode. r=kinetik.
This commit is contained in:
Родитель
f6179e5445
Коммит
4265c0e543
|
@ -6,6 +6,7 @@
|
|||
#include "gtest/gtest.h"
|
||||
|
||||
#include "mozilla/TaskQueue.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "MediaEventSource.h"
|
||||
#include "VideoUtils.h"
|
||||
|
||||
|
@ -294,3 +295,29 @@ TEST(MediaEventSource, CopyEvent2)
|
|||
listener1.Disconnect();
|
||||
listener2.Disconnect();
|
||||
}
|
||||
|
||||
/*
|
||||
* Test move-only types.
|
||||
*/
|
||||
TEST(MediaEventSource, MoveOnly)
|
||||
{
|
||||
nsRefPtr<TaskQueue> queue = new TaskQueue(
|
||||
GetMediaThreadPool(MediaThreadType::PLAYBACK));
|
||||
|
||||
MediaEventProducer<UniquePtr<int>, ListenerMode::Exclusive> source;
|
||||
|
||||
auto func = [] (UniquePtr<int>&& aEvent) {
|
||||
EXPECT_EQ(*aEvent, 20);
|
||||
};
|
||||
MediaEventListener listener = source.Connect(queue, func);
|
||||
|
||||
// It is OK to pass an rvalue which is move-only.
|
||||
source.Notify(UniquePtr<int>(new int(20)));
|
||||
// It is an error to pass an lvalue which is move-only.
|
||||
// UniquePtr<int> event(new int(30));
|
||||
// source.Notify(event);
|
||||
|
||||
queue->BeginShutdown();
|
||||
queue->AwaitShutdownAndIdle();
|
||||
listener.Disconnect();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче