style: unify identifier naming per updated conventions
Automated with clang-tidy readability-identifier-naming (config added to .clang-tidy) plus scripted passes, per the updated rules now documented in CONTRIBUTING.md: - types (class/struct/enum/alias/template params): PascalCase - functions, variables, members: snake_case (incl. rational -> Rational) - private/protected members: trailing underscore; static member variables likewise (instance_, available_themes_) - constants and enum values: snake_case (kLinear -> k_linear, F32P -> f32p); ALL_CAPS reserved for macros - macros: OAK_ prefix (OLIVE_ADD_TEST/OLIVE_ASSERT/OLIVE_CONFIG -> OAK_ADD_TEST/OAK_ASSERT/OAK_CONFIG, GL_PREAMBLE -> OAK_GL_PREAMBLE, include guards -> OAK_*) - file names: all lowercase (Current/Plugin/OliveHost/OliveClip/ OlivePluginInstance -> current/plugin/olivehost/oliveclip/ oliveplugininstance) - getters share the member name sans underscore, setters set_foo() - Qt and third-party (OpenFX) virtual overrides and framework callbacks keep their original names (exempt in .clang-tidy) Manual follow-ups required where automation could not reach: - string-based QMetaObject/SIGNAL/SLOT references updated to renamed methods (AddTask, CreatedFile, DeleteSpecificFile, moveSelectionUp, ...) - macro bodies referencing renamed methods (OLIVE_CONFIG, NODE_DEFAULT_DESTRUCTOR, MANAGEDDISPLAYWIDGET_*) - self-shadowing locals renamed where signals/methods became same-named (size_changed, worker_count, selected_items, import param, filters) - third_party OFX member/namespace usages restored (OFX::Host::*, _created, _clipPrefsDirty, createInstance, clearPersistentMessage) - STL protocol aliases restored (const_iterator) with .clang-tidy ignore rules; qHash overloads restored Full build and test suite pass: ctest 4/4, ~1960 gtest cases green.
This commit is contained in:
@@ -34,58 +34,58 @@ using namespace olive::ipc;
|
||||
|
||||
TEST(SpscRingBuffer, BasicPushPopAndCapacity)
|
||||
{
|
||||
std::vector<uint8_t> mem(SpscRingBuffer::BytesNeeded(4));
|
||||
SpscRingBuffer *ring = SpscRingBuffer::Create(mem.data(), 4);
|
||||
std::vector<uint8_t> mem(SpscRingBuffer::bytes_needed(4));
|
||||
SpscRingBuffer *ring = SpscRingBuffer::create(mem.data(), 4);
|
||||
|
||||
EXPECT_TRUE(ring->IsEmptyApprox());
|
||||
EXPECT_TRUE(ring->is_empty_approx());
|
||||
|
||||
uint32_t v = 0;
|
||||
EXPECT_FALSE(ring->Pop(&v)); // empty
|
||||
EXPECT_FALSE(ring->pop(&v)); // empty
|
||||
|
||||
// Capacity 4 holds at most 3 entries (one slot reserved to disambiguate full/empty).
|
||||
EXPECT_TRUE(ring->Push(10));
|
||||
EXPECT_TRUE(ring->Push(20));
|
||||
EXPECT_TRUE(ring->Push(30));
|
||||
EXPECT_FALSE(ring->Push(40)); // full
|
||||
EXPECT_TRUE(ring->push(10));
|
||||
EXPECT_TRUE(ring->push(20));
|
||||
EXPECT_TRUE(ring->push(30));
|
||||
EXPECT_FALSE(ring->push(40)); // full
|
||||
|
||||
EXPECT_TRUE(ring->Pop(&v));
|
||||
EXPECT_TRUE(ring->pop(&v));
|
||||
EXPECT_EQ(v, 10u);
|
||||
EXPECT_TRUE(ring->Pop(&v));
|
||||
EXPECT_TRUE(ring->pop(&v));
|
||||
EXPECT_EQ(v, 20u);
|
||||
EXPECT_TRUE(ring->Pop(&v));
|
||||
EXPECT_TRUE(ring->pop(&v));
|
||||
EXPECT_EQ(v, 30u);
|
||||
EXPECT_FALSE(ring->Pop(&v)); // empty again
|
||||
EXPECT_FALSE(ring->pop(&v)); // empty again
|
||||
}
|
||||
|
||||
TEST(SpscRingBuffer, WrapAround)
|
||||
{
|
||||
std::vector<uint8_t> mem(SpscRingBuffer::BytesNeeded(4));
|
||||
SpscRingBuffer *ring = SpscRingBuffer::Create(mem.data(), 4);
|
||||
std::vector<uint8_t> mem(SpscRingBuffer::bytes_needed(4));
|
||||
SpscRingBuffer *ring = SpscRingBuffer::create(mem.data(), 4);
|
||||
|
||||
// Repeatedly pushing then popping single values forces the cursors past the backing array end.
|
||||
for (uint32_t i = 0; i < 100; i++) {
|
||||
ASSERT_TRUE(ring->Push(i));
|
||||
ASSERT_TRUE(ring->push(i));
|
||||
uint32_t got = 0;
|
||||
ASSERT_TRUE(ring->Pop(&got));
|
||||
ASSERT_TRUE(ring->pop(&got));
|
||||
EXPECT_EQ(got, i);
|
||||
}
|
||||
EXPECT_TRUE(ring->IsEmptyApprox());
|
||||
EXPECT_TRUE(ring->is_empty_approx());
|
||||
}
|
||||
|
||||
TEST(SpscRingBuffer, ConcurrentProducerConsumer)
|
||||
{
|
||||
constexpr uint32_t kCapacity = 1024;
|
||||
constexpr uint32_t kCount =
|
||||
constexpr uint32_t k_capacity = 1024;
|
||||
constexpr uint32_t k_count =
|
||||
2'000'000; // values 0..kCount-1 streamed through the ring
|
||||
|
||||
std::vector<uint8_t> mem(SpscRingBuffer::BytesNeeded(kCapacity));
|
||||
SpscRingBuffer *ring = SpscRingBuffer::Create(mem.data(), kCapacity);
|
||||
std::vector<uint8_t> mem(SpscRingBuffer::bytes_needed(k_capacity));
|
||||
SpscRingBuffer *ring = SpscRingBuffer::create(mem.data(), k_capacity);
|
||||
|
||||
std::atomic<bool> order_ok{ true };
|
||||
|
||||
std::thread producer([&] {
|
||||
for (uint32_t i = 0; i < kCount; i++) {
|
||||
while (!ring->Push(i)) {
|
||||
for (uint32_t i = 0; i < k_count; i++) {
|
||||
while (!ring->push(i)) {
|
||||
std::this_thread::yield(); // buffer full, spin until consumer drains
|
||||
}
|
||||
}
|
||||
@@ -94,9 +94,9 @@ TEST(SpscRingBuffer, ConcurrentProducerConsumer)
|
||||
std::thread consumer([&] {
|
||||
// Every value must arrive exactly once and strictly in order (FIFO).
|
||||
uint32_t expected = 0;
|
||||
while (expected < kCount) {
|
||||
while (expected < k_count) {
|
||||
uint32_t got = 0;
|
||||
if (ring->Pop(&got)) {
|
||||
if (ring->pop(&got)) {
|
||||
if (got != expected) {
|
||||
order_ok.store(false);
|
||||
return;
|
||||
@@ -112,7 +112,7 @@ TEST(SpscRingBuffer, ConcurrentProducerConsumer)
|
||||
consumer.join();
|
||||
|
||||
EXPECT_TRUE(order_ok.load());
|
||||
EXPECT_TRUE(ring->IsEmptyApprox());
|
||||
EXPECT_TRUE(ring->is_empty_approx());
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
@@ -121,109 +121,109 @@ TEST(SpscRingBuffer, ConcurrentProducerConsumer)
|
||||
|
||||
TEST(FrameSlotPool, SingleThreadedHandoff)
|
||||
{
|
||||
constexpr uint32_t kSlots = 3;
|
||||
constexpr size_t kSlotBytes = 256;
|
||||
constexpr uint32_t k_slots = 3;
|
||||
constexpr size_t k_slot_bytes = 256;
|
||||
|
||||
std::vector<uint8_t> mem(FrameSlotPool::BytesNeeded(kSlots, kSlotBytes));
|
||||
std::vector<uint8_t> mem(FrameSlotPool::bytes_needed(k_slots, k_slot_bytes));
|
||||
FrameSlotPool filler =
|
||||
FrameSlotPool::Create(mem.data(), kSlots, kSlotBytes);
|
||||
FrameSlotPool drainer = FrameSlotPool::Attach(mem.data());
|
||||
FrameSlotPool::create(mem.data(), k_slots, k_slot_bytes);
|
||||
FrameSlotPool drainer = FrameSlotPool::attach(mem.data());
|
||||
|
||||
ASSERT_TRUE(filler.IsValid());
|
||||
ASSERT_TRUE(drainer.IsValid());
|
||||
EXPECT_EQ(drainer.slot_count(), kSlots);
|
||||
EXPECT_EQ(drainer.slot_data_bytes(), kSlotBytes);
|
||||
ASSERT_TRUE(filler.is_valid());
|
||||
ASSERT_TRUE(drainer.is_valid());
|
||||
EXPECT_EQ(drainer.slot_count(), k_slots);
|
||||
EXPECT_EQ(drainer.slot_data_bytes(), k_slot_bytes);
|
||||
|
||||
// Fill one slot with a recognizable pattern + metadata, publish, then drain and verify.
|
||||
uint32_t idx = 0;
|
||||
ASSERT_TRUE(filler.Acquire(&idx));
|
||||
ASSERT_TRUE(filler.acquire(&idx));
|
||||
|
||||
auto *data = static_cast<uint8_t *>(filler.SlotData(idx));
|
||||
for (size_t i = 0; i < kSlotBytes; i++) {
|
||||
auto *data = static_cast<uint8_t *>(filler.slot_data(idx));
|
||||
for (size_t i = 0; i < k_slot_bytes; i++) {
|
||||
data[i] = uint8_t(i & 0xFF);
|
||||
}
|
||||
FrameSlotMeta *meta = filler.Meta(idx);
|
||||
FrameSlotMeta *meta = filler.meta(idx);
|
||||
meta->id = 4242;
|
||||
meta->width = 16;
|
||||
meta->height = 8;
|
||||
meta->data_size = int32_t(kSlotBytes);
|
||||
meta->data_size = int32_t(k_slot_bytes);
|
||||
|
||||
ASSERT_TRUE(filler.Publish(idx));
|
||||
ASSERT_TRUE(filler.publish(idx));
|
||||
|
||||
uint32_t got_idx = 0;
|
||||
ASSERT_TRUE(drainer.Consume(&got_idx));
|
||||
ASSERT_TRUE(drainer.consume(&got_idx));
|
||||
EXPECT_EQ(got_idx, idx);
|
||||
|
||||
const FrameSlotMeta *got_meta = drainer.Meta(got_idx);
|
||||
const FrameSlotMeta *got_meta = drainer.meta(got_idx);
|
||||
EXPECT_EQ(got_meta->id, 4242);
|
||||
EXPECT_EQ(got_meta->width, 16);
|
||||
|
||||
const auto *got_data =
|
||||
static_cast<const uint8_t *>(drainer.SlotData(got_idx));
|
||||
for (size_t i = 0; i < kSlotBytes; i++) {
|
||||
static_cast<const uint8_t *>(drainer.slot_data(got_idx));
|
||||
for (size_t i = 0; i < k_slot_bytes; i++) {
|
||||
ASSERT_EQ(got_data[i], uint8_t(i & 0xFF));
|
||||
}
|
||||
|
||||
EXPECT_TRUE(drainer.Release(got_idx));
|
||||
EXPECT_TRUE(drainer.release(got_idx));
|
||||
}
|
||||
|
||||
TEST(FrameSlotPool, ExhaustionAndRefill)
|
||||
{
|
||||
constexpr uint32_t kSlots = 3;
|
||||
constexpr size_t kSlotBytes = 64;
|
||||
constexpr uint32_t k_slots = 3;
|
||||
constexpr size_t k_slot_bytes = 64;
|
||||
|
||||
std::vector<uint8_t> mem(FrameSlotPool::BytesNeeded(kSlots, kSlotBytes));
|
||||
FrameSlotPool pool = FrameSlotPool::Create(mem.data(), kSlots, kSlotBytes);
|
||||
std::vector<uint8_t> mem(FrameSlotPool::bytes_needed(k_slots, k_slot_bytes));
|
||||
FrameSlotPool pool = FrameSlotPool::create(mem.data(), k_slots, k_slot_bytes);
|
||||
|
||||
// Acquire every slot, then confirm the pool reports empty.
|
||||
std::vector<uint32_t> held;
|
||||
for (uint32_t i = 0; i < kSlots; i++) {
|
||||
for (uint32_t i = 0; i < k_slots; i++) {
|
||||
uint32_t a = 0;
|
||||
ASSERT_TRUE(pool.Acquire(&a));
|
||||
ASSERT_TRUE(pool.acquire(&a));
|
||||
held.push_back(a);
|
||||
}
|
||||
uint32_t overflow = 0;
|
||||
EXPECT_FALSE(pool.Acquire(&overflow)); // pool exhausted
|
||||
EXPECT_FALSE(pool.acquire(&overflow)); // pool exhausted
|
||||
|
||||
// Publishing then consuming + releasing returns the slots to the free pool.
|
||||
for (uint32_t idx : held) {
|
||||
ASSERT_TRUE(pool.Publish(idx));
|
||||
ASSERT_TRUE(pool.publish(idx));
|
||||
}
|
||||
for (uint32_t i = 0; i < kSlots; i++) {
|
||||
for (uint32_t i = 0; i < k_slots; i++) {
|
||||
uint32_t c = 0;
|
||||
ASSERT_TRUE(pool.Consume(&c));
|
||||
ASSERT_TRUE(pool.Release(c));
|
||||
ASSERT_TRUE(pool.consume(&c));
|
||||
ASSERT_TRUE(pool.release(c));
|
||||
}
|
||||
uint32_t again = 0;
|
||||
EXPECT_TRUE(pool.Acquire(&again)); // free again
|
||||
EXPECT_TRUE(pool.acquire(&again)); // free again
|
||||
}
|
||||
|
||||
TEST(FrameSlotPool, ConcurrentFillDrainIntegrity)
|
||||
{
|
||||
constexpr uint32_t kSlots = 8;
|
||||
constexpr size_t kSlotBytes = 4096;
|
||||
constexpr int64_t kFrames = 200'000;
|
||||
constexpr uint32_t k_slots = 8;
|
||||
constexpr size_t k_slot_bytes = 4096;
|
||||
constexpr int64_t k_frames = 200'000;
|
||||
|
||||
std::vector<uint8_t> mem(FrameSlotPool::BytesNeeded(kSlots, kSlotBytes));
|
||||
std::vector<uint8_t> mem(FrameSlotPool::bytes_needed(k_slots, k_slot_bytes));
|
||||
FrameSlotPool filler =
|
||||
FrameSlotPool::Create(mem.data(), kSlots, kSlotBytes);
|
||||
FrameSlotPool drainer = FrameSlotPool::Attach(mem.data());
|
||||
FrameSlotPool::create(mem.data(), k_slots, k_slot_bytes);
|
||||
FrameSlotPool drainer = FrameSlotPool::attach(mem.data());
|
||||
|
||||
std::atomic<bool> integrity_ok{ true };
|
||||
|
||||
// Filler: for each frame id, acquire a slot, stamp the id into meta and a pattern into the data,
|
||||
// publish. Spins when no slot is free (this is the natural backpressure path).
|
||||
std::thread fill_thread([&] {
|
||||
for (int64_t id = 0; id < kFrames; id++) {
|
||||
for (int64_t id = 0; id < k_frames; id++) {
|
||||
uint32_t idx = 0;
|
||||
while (!filler.Acquire(&idx)) {
|
||||
while (!filler.acquire(&idx)) {
|
||||
std::this_thread::yield();
|
||||
}
|
||||
filler.Meta(idx)->id = id;
|
||||
auto *d = static_cast<uint8_t *>(filler.SlotData(idx));
|
||||
filler.meta(idx)->id = id;
|
||||
auto *d = static_cast<uint8_t *>(filler.slot_data(idx));
|
||||
const uint8_t pat = uint8_t(id & 0xFF);
|
||||
memset(d, pat, kSlotBytes);
|
||||
while (!filler.Publish(idx)) {
|
||||
memset(d, pat, k_slot_bytes);
|
||||
while (!filler.publish(idx)) {
|
||||
std::this_thread::yield(); // ready ring transiently full
|
||||
}
|
||||
}
|
||||
@@ -233,24 +233,24 @@ TEST(FrameSlotPool, ConcurrentFillDrainIntegrity)
|
||||
// then release the slot back to the filler.
|
||||
std::thread drain_thread([&] {
|
||||
int64_t expected = 0;
|
||||
while (expected < kFrames) {
|
||||
while (expected < k_frames) {
|
||||
uint32_t idx = 0;
|
||||
if (!drainer.Consume(&idx)) {
|
||||
if (!drainer.consume(&idx)) {
|
||||
std::this_thread::yield();
|
||||
continue;
|
||||
}
|
||||
const FrameSlotMeta *m = drainer.Meta(idx);
|
||||
const FrameSlotMeta *m = drainer.meta(idx);
|
||||
if (m->id != expected) {
|
||||
integrity_ok.store(false);
|
||||
return;
|
||||
}
|
||||
const auto *d = static_cast<const uint8_t *>(drainer.SlotData(idx));
|
||||
const auto *d = static_cast<const uint8_t *>(drainer.slot_data(idx));
|
||||
const uint8_t pat = uint8_t(expected & 0xFF);
|
||||
if (d[0] != pat || d[kSlotBytes - 1] != pat) {
|
||||
if (d[0] != pat || d[k_slot_bytes - 1] != pat) {
|
||||
integrity_ok.store(false);
|
||||
return;
|
||||
}
|
||||
while (!drainer.Release(idx)) {
|
||||
while (!drainer.release(idx)) {
|
||||
std::this_thread::yield();
|
||||
}
|
||||
expected++;
|
||||
@@ -283,7 +283,7 @@ TEST(IpcMessage, TypedRoundTrip)
|
||||
hs.output_slots = 6;
|
||||
hs.slot_data_bytes = 256ll * 1024 * 1024;
|
||||
hs.input_slot_data_bytes = 128ll * 1024 * 1024;
|
||||
ASSERT_TRUE(WriteMessage(&dev, hs.ToJson()));
|
||||
ASSERT_TRUE(write_message(&dev, hs.to_json()));
|
||||
|
||||
RenderFrameMsg rf;
|
||||
rf.ticket_id = 99;
|
||||
@@ -297,12 +297,12 @@ TEST(IpcMessage, TypedRoundTrip)
|
||||
rf.mode = 1;
|
||||
rf.input_slot = 2;
|
||||
rf.input_slots = { 2, 3 };
|
||||
ASSERT_TRUE(WriteMessage(&dev, rf.ToJson()));
|
||||
ASSERT_TRUE(write_message(&dev, rf.to_json()));
|
||||
|
||||
FrameReadyMsg fr;
|
||||
fr.ticket_id = 99;
|
||||
fr.output_slot = 2;
|
||||
ASSERT_TRUE(WriteMessage(&dev, fr.ToJson()));
|
||||
ASSERT_TRUE(write_message(&dev, fr.to_json()));
|
||||
|
||||
dev.close();
|
||||
|
||||
@@ -310,10 +310,10 @@ TEST(IpcMessage, TypedRoundTrip)
|
||||
QJsonObject obj;
|
||||
bool ok = false;
|
||||
|
||||
ASSERT_TRUE(ReadMessage(&reader, &obj, &ok));
|
||||
ASSERT_TRUE(read_message(&reader, &obj, &ok));
|
||||
ASSERT_TRUE(ok);
|
||||
HandshakeMsg hs2;
|
||||
ASSERT_TRUE(HandshakeMsg::FromJson(obj, &hs2));
|
||||
ASSERT_TRUE(HandshakeMsg::from_json(obj, &hs2));
|
||||
EXPECT_EQ(hs2.protocol_version, 1);
|
||||
EXPECT_EQ(hs2.shm_key, hs.shm_key);
|
||||
EXPECT_EQ(hs2.input_shm_key, hs.input_shm_key);
|
||||
@@ -322,10 +322,10 @@ TEST(IpcMessage, TypedRoundTrip)
|
||||
EXPECT_EQ(hs2.slot_data_bytes, hs.slot_data_bytes);
|
||||
EXPECT_EQ(hs2.input_slot_data_bytes, hs.input_slot_data_bytes);
|
||||
|
||||
ASSERT_TRUE(ReadMessage(&reader, &obj, &ok));
|
||||
ASSERT_TRUE(read_message(&reader, &obj, &ok));
|
||||
ASSERT_TRUE(ok);
|
||||
RenderFrameMsg rf2;
|
||||
ASSERT_TRUE(RenderFrameMsg::FromJson(obj, &rf2));
|
||||
ASSERT_TRUE(RenderFrameMsg::from_json(obj, &rf2));
|
||||
EXPECT_EQ(rf2.ticket_id, 99);
|
||||
EXPECT_EQ(rf2.node_uuid, rf.node_uuid);
|
||||
EXPECT_EQ(rf2.time_num, 1001);
|
||||
@@ -337,15 +337,15 @@ TEST(IpcMessage, TypedRoundTrip)
|
||||
EXPECT_EQ(rf2.input_slots[0], 2);
|
||||
EXPECT_EQ(rf2.input_slots[1], 3);
|
||||
|
||||
ASSERT_TRUE(ReadMessage(&reader, &obj, &ok));
|
||||
ASSERT_TRUE(read_message(&reader, &obj, &ok));
|
||||
ASSERT_TRUE(ok);
|
||||
FrameReadyMsg fr2;
|
||||
ASSERT_TRUE(FrameReadyMsg::FromJson(obj, &fr2));
|
||||
ASSERT_TRUE(FrameReadyMsg::from_json(obj, &fr2));
|
||||
EXPECT_EQ(fr2.ticket_id, 99);
|
||||
EXPECT_EQ(fr2.output_slot, 2);
|
||||
|
||||
// No more complete lines remain.
|
||||
EXPECT_FALSE(ReadMessage(&reader, &obj, &ok));
|
||||
EXPECT_FALSE(read_message(&reader, &obj, &ok));
|
||||
}
|
||||
|
||||
TEST(IpcMessage, PartialFrameByteByByte)
|
||||
@@ -353,7 +353,7 @@ TEST(IpcMessage, PartialFrameByteByByte)
|
||||
CancelMsg c;
|
||||
c.ticket_id = 7;
|
||||
const QByteArray full =
|
||||
QByteArray(QJsonDocument(c.ToJson()).toJson(QJsonDocument::Compact)) +
|
||||
QByteArray(QJsonDocument(c.to_json()).toJson(QJsonDocument::Compact)) +
|
||||
'\n';
|
||||
|
||||
// Feed the bytes one at a time; ReadMessage must return false until the terminating '\n'.
|
||||
@@ -362,14 +362,14 @@ TEST(IpcMessage, PartialFrameByteByByte)
|
||||
bool ok = false;
|
||||
for (int i = 0; i < full.size() - 1; i++) {
|
||||
reader.append(full.at(i));
|
||||
ASSERT_FALSE(ReadMessage(&reader, &obj, &ok)); // no complete line yet
|
||||
ASSERT_FALSE(read_message(&reader, &obj, &ok)); // no complete line yet
|
||||
}
|
||||
reader.append(full.at(full.size() - 1)); // the trailing newline
|
||||
ASSERT_TRUE(ReadMessage(&reader, &obj, &ok));
|
||||
ASSERT_TRUE(read_message(&reader, &obj, &ok));
|
||||
ASSERT_TRUE(ok);
|
||||
|
||||
CancelMsg c2;
|
||||
ASSERT_TRUE(CancelMsg::FromJson(obj, &c2));
|
||||
ASSERT_TRUE(CancelMsg::from_json(obj, &c2));
|
||||
EXPECT_EQ(c2.ticket_id, 7);
|
||||
}
|
||||
|
||||
@@ -379,7 +379,7 @@ TEST(IpcMessage, MalformedLineIsSkipped)
|
||||
QJsonObject obj;
|
||||
bool ok = true;
|
||||
// A complete but malformed line is consumed and reported as not-ok, leaving the buffer drained.
|
||||
EXPECT_FALSE(ReadMessage(&reader, &obj, &ok));
|
||||
EXPECT_FALSE(read_message(&reader, &obj, &ok));
|
||||
EXPECT_FALSE(ok);
|
||||
EXPECT_TRUE(reader.isEmpty());
|
||||
}
|
||||
@@ -389,7 +389,7 @@ TEST(IpcMessage, BlankLinesAreSkippedSilently)
|
||||
CancelMsg c;
|
||||
c.ticket_id = 7;
|
||||
const QByteArray line =
|
||||
QByteArray(QJsonDocument(c.ToJson()).toJson(QJsonDocument::Compact)) +
|
||||
QByteArray(QJsonDocument(c.to_json()).toJson(QJsonDocument::Compact)) +
|
||||
'\n';
|
||||
|
||||
// Blank lines (even repeated) are consumed without flagging an error, and
|
||||
@@ -397,16 +397,16 @@ TEST(IpcMessage, BlankLinesAreSkippedSilently)
|
||||
QByteArray reader = QByteArray("\n \n\n") + line;
|
||||
QJsonObject obj;
|
||||
bool ok = false;
|
||||
ASSERT_TRUE(ReadMessage(&reader, &obj, &ok));
|
||||
ASSERT_TRUE(read_message(&reader, &obj, &ok));
|
||||
EXPECT_TRUE(ok);
|
||||
|
||||
CancelMsg c2;
|
||||
ASSERT_TRUE(CancelMsg::FromJson(obj, &c2));
|
||||
ASSERT_TRUE(CancelMsg::from_json(obj, &c2));
|
||||
EXPECT_EQ(c2.ticket_id, 7);
|
||||
|
||||
// Only blank lines left: nothing more to read, but still not an error.
|
||||
ok = true;
|
||||
EXPECT_FALSE(ReadMessage(&reader, &obj, &ok));
|
||||
EXPECT_FALSE(read_message(&reader, &obj, &ok));
|
||||
EXPECT_TRUE(ok);
|
||||
EXPECT_TRUE(reader.isEmpty());
|
||||
}
|
||||
@@ -416,8 +416,8 @@ TEST(IpcMessage, WrongTypeRejected)
|
||||
// FromJson must reject an object whose "type" does not match the target struct.
|
||||
HandshakeMsg hs;
|
||||
hs.protocol_version = 1;
|
||||
const QJsonObject obj = hs.ToJson();
|
||||
const QJsonObject obj = hs.to_json();
|
||||
|
||||
RenderFrameMsg rf;
|
||||
EXPECT_FALSE(RenderFrameMsg::FromJson(obj, &rf));
|
||||
EXPECT_FALSE(RenderFrameMsg::from_json(obj, &rf));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user