#include <stddef.h>
#include <cmath>
#include "base/base64.h"
#include "base/files/file_util.h"
#include "base/path_service.h"
#include "base/pickle.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/loader/http_body_element_type.h"
#include "third_party/blink/public/common/page_state/page_state_serialization.h"
namespace blink {
namespace {
base::FilePath GetFilePath() { … }
template <typename T>
void ExpectEquality(const T& expected, const T& actual) { … }
template <typename T>
void ExpectEquality(const std::vector<T>& expected,
const std::vector<T>& actual) { … }
template <>
void ExpectEquality(const network::DataElement& expected,
const network::DataElement& actual) { … }
template <>
void ExpectEquality(const ExplodedHttpBody& expected,
const ExplodedHttpBody& actual) { … }
template <>
void ExpectEquality(const ExplodedFrameState& expected,
const ExplodedFrameState& actual) { … }
void ExpectEquality(const ExplodedPageState& expected,
const ExplodedPageState& actual) { … }
class PageStateSerializationTest : public testing::Test { … };
TEST_F(PageStateSerializationTest, InitiatorOriginAssign) { … }
TEST_F(PageStateSerializationTest, BasicEmpty) { … }
TEST_F(PageStateSerializationTest, BasicFrame) { … }
TEST_F(PageStateSerializationTest, BasicFramePOST) { … }
TEST_F(PageStateSerializationTest, BasicFrameSet) { … }
TEST_F(PageStateSerializationTest, BasicFrameSetPOST) { … }
TEST_F(PageStateSerializationTest, BadMessagesTest1) { … }
TEST_F(PageStateSerializationTest, BadMessagesTest2) { … }
TEST_F(PageStateSerializationTest, LegacyEncodePageStateFrozen) { … }
TEST_F(PageStateSerializationTest, ScrollAnchorSelectorLengthLimited) { … }
#if 0
TEST_F(PageStateSerializationTest, DumpExpectedPageStateForBackwardsCompat) {
ExplodedPageState state;
PopulatePageStateForBackwardsCompatTest(&state, 9999);
std::string encoded;
EncodePageState(state, &encoded);
std::string base64 = base::Base64Encode(encoded);
base::FilePath path;
base::PathService::Get(base::DIR_TEMP, &path);
path = path.AppendASCII("expected.dat");
FILE* fp = base::OpenFile(path, "wb");
ASSERT_TRUE(fp);
const size_t kRowSize = 76;
for (size_t offset = 0; offset < base64.size(); offset += kRowSize) {
size_t length = std::min(base64.size() - offset, kRowSize);
std::string segment(&base64[offset], length);
segment.push_back('\n');
ASSERT_EQ(1U, fwrite(segment.data(), segment.size(), 1, fp));
}
fclose(fp);
}
#endif
#if !BUILDFLAG(IS_ANDROID)
TEST_F(PageStateSerializationTest, BackwardsCompat_v11) { … }
#endif
TEST_F(PageStateSerializationTest, BackwardsCompat_v12) { … }
TEST_F(PageStateSerializationTest, BackwardsCompat_v13) { … }
TEST_F(PageStateSerializationTest, BackwardsCompat_v14) { … }
TEST_F(PageStateSerializationTest, BackwardsCompat_v15) { … }
TEST_F(PageStateSerializationTest, BackwardsCompat_v16) { … }
TEST_F(PageStateSerializationTest, BackwardsCompat_v18) { … }
TEST_F(PageStateSerializationTest, BackwardsCompat_v20) { … }
TEST_F(PageStateSerializationTest, BackwardsCompat_v21) { … }
TEST_F(PageStateSerializationTest, BackwardsCompat_v22) { … }
TEST_F(PageStateSerializationTest, BackwardsCompat_v23) { … }
TEST_F(PageStateSerializationTest, BackwardsCompat_v24) { … }
TEST_F(PageStateSerializationTest, BackwardsCompat_v25) { … }
TEST_F(PageStateSerializationTest, BackwardsCompat_v26) { … }
TEST_F(PageStateSerializationTest, BackwardsCompat_v27) { … }
TEST_F(PageStateSerializationTest, BackwardsCompat_v28) { … }
TEST_F(PageStateSerializationTest, BackwardsCompat_v29) { … }
TEST_F(PageStateSerializationTest, BackwardsCompat_v30) { … }
TEST_F(PageStateSerializationTest, BackwardsCompat_v31) { … }
TEST_F(PageStateSerializationTest, BackwardsCompat_v32) { … }
TEST_F(PageStateSerializationTest, BackwardsCompat_v33) { … }
TEST_F(PageStateSerializationTest, BackwardsCompat_ReferencedFiles) { … }
TEST_F(PageStateSerializationTest, BackwardsCompat_UrlString) { … }
TEST_F(PageStateSerializationTest, BackwardsCompat_Referrer) { … }
TEST_F(PageStateSerializationTest, BackwardsCompat_Target) { … }
TEST_F(PageStateSerializationTest, BackwardsCompat_StateObject) { … }
TEST_F(PageStateSerializationTest, BackwardsCompat_DocumentState) { … }
TEST_F(PageStateSerializationTest, BackwardsCompat_ScrollRestorationType) { … }
TEST_F(PageStateSerializationTest, BackwardsCompat_VisualViewportScrollOffset) { … }
TEST_F(PageStateSerializationTest, BackwardsCompat_ScrollOffset) { … }
TEST_F(PageStateSerializationTest, BackwardsCompat_ReferrerPolicy) { … }
TEST_F(PageStateSerializationTest, BackwardsCompat_HttpBody) { … }
}
}