
Move PrepareReplyMessage() to a util file so that it can be used in other files in future CLs (see https://crrev.com/c/5941005). Remove a redundant param for setting the reply type. This can already be retrieved from the `message` param. Add CHECKs before accessing pointers. Bug: 373672165 Change-Id: I88aaef1bdf2cde42309b6a4e4a06046fb3e790df Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5941004 Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com> Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Andy Phan <andyphan@chromium.org> Cr-Commit-Position: refs/heads/main@{#1370814}
30 lines
843 B
C++
30 lines
843 B
C++
// Copyright 2024 The Chromium Authors
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "pdf/message_util.h"
|
|
|
|
#include "base/test/values_test_util.h"
|
|
#include "base/values.h"
|
|
#include "testing/gtest/include/gtest/gtest.h"
|
|
|
|
namespace chrome_pdf {
|
|
|
|
TEST(PrepareReplyMessageTest, BasicReply) {
|
|
base::Value::Dict message;
|
|
message.Set("type", "typeBasic");
|
|
message.Set("messageId", "messageIdBasic");
|
|
|
|
base::Value::Dict reply = PrepareReplyMessage(message);
|
|
|
|
const std::string* reply_type = reply.FindString("type");
|
|
ASSERT_TRUE(reply_type);
|
|
EXPECT_EQ("typeBasicReply", *reply_type);
|
|
|
|
const std::string* reply_message_id = reply.FindString("messageId");
|
|
ASSERT_TRUE(reply_message_id);
|
|
EXPECT_EQ("messageIdBasic", *reply_message_id);
|
|
}
|
|
|
|
} // namespace chrome_pdf
|