32 lines
1.1 KiB
C++
32 lines
1.1 KiB
C++
// Copyright 2013 Google Inc. All Rights Reserved.
|
|
|
|
// Review the TestHost_4 class below to observe how the CDM interfaces with
|
|
// the host application.
|
|
|
|
#include "test_host_4_file_io.h"
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
void TestHost_4_FileIO::Open(const char* file_name, uint32_t file_name_size) {
|
|
ASSERT_EQ(0, file_name_.size());
|
|
file_name_.assign(file_name, file_name_size);
|
|
client_->OnOpenComplete(cdm::FileIOClient::kSuccess);
|
|
}
|
|
|
|
void TestHost_4_FileIO::Read() {
|
|
ASSERT_NE(0, file_name_.size());
|
|
const std::string& data = host_->file_store[file_name_];
|
|
client_->OnReadComplete(cdm::FileIOClient::kSuccess,
|
|
reinterpret_cast<const uint8_t*>(data.data()),
|
|
data.size());
|
|
}
|
|
|
|
void TestHost_4_FileIO::Write(const uint8_t* data, uint32_t data_size) {
|
|
ASSERT_NE(0, file_name_.size());
|
|
host_->file_store[file_name_].assign(reinterpret_cast<const char*>(data),
|
|
data_size);
|
|
client_->OnWriteComplete(cdm::FileIOClient::kSuccess);
|
|
}
|
|
|
|
void TestHost_4_FileIO::Close() { delete this; }
|