Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Unified Diff: components/copresence/rpc/rpc_handler_unittest.cc

Issue 469883002: Using API key specified from js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding fingerprint test Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/copresence/rpc/rpc_handler_unittest.cc
diff --git a/components/copresence/rpc/rpc_handler_unittest.cc b/components/copresence/rpc/rpc_handler_unittest.cc
index bcdace5254d61b84b0254c476ab1167382b18914..4607b58b21d25119aabf4edb73e62b7f19052165 100644
--- a/components/copresence/rpc/rpc_handler_unittest.cc
+++ b/components/copresence/rpc/rpc_handler_unittest.cc
@@ -25,6 +25,8 @@ namespace copresence {
namespace {
+const char kChromeVersion[] = "Chrome Version String";
+
void AddMessageWithStrategy(ReportRequest* report,
BroadcastScanConfiguration strategy) {
report->mutable_manage_messages_request()->add_message_to_publish()
@@ -83,10 +85,12 @@ class FakeDirectiveHandler : public DirectiveHandler {
class RpcHandlerTest : public testing::Test, public CopresenceClientDelegate {
public:
- RpcHandlerTest() : rpc_handler_(this), status_(SUCCESS) {
+ RpcHandlerTest() : rpc_handler_(this), status_(SUCCESS), api_key_("API key") {
rpc_handler_.server_post_callback_ =
base::Bind(&RpcHandlerTest::CaptureHttpPost, base::Unretained(this));
rpc_handler_.device_id_ = "Device ID";
+
+ fingerprint_.set_platform_version(kChromeVersion);
}
void CaptureHttpPost(
@@ -167,8 +171,12 @@ class RpcHandlerTest : public testing::Test, public CopresenceClientDelegate {
return NULL;
}
- virtual const std::string GetPlatformVersionString() const OVERRIDE {
- return "Version String";
+ virtual const DeviceFingerprint& GetDeviceFingerprint() const OVERRIDE {
+ return fingerprint_;
+ }
+
+ virtual const std::string& GetAPIKey() const OVERRIDE {
+ return api_key_;
}
virtual WhispernetClient* GetWhispernetClient() OVERRIDE {
@@ -180,10 +188,12 @@ class RpcHandlerTest : public testing::Test, public CopresenceClientDelegate {
base::MessageLoop message_loop_;
RpcHandler rpc_handler_;
+ CopresenceStatus status_;
+ std::string api_key_;
+ DeviceFingerprint fingerprint_;
std::string rpc_name_;
scoped_ptr<MessageLite> request_proto_;
- CopresenceStatus status_;
std::map<std::string, std::vector<Message> > messages_by_subscription_;
};
@@ -287,11 +297,14 @@ TEST_F(RpcHandlerTest, CreateRequestHeader) {
StatusCallback());
EXPECT_EQ(RpcHandler::kReportRequestRpcName, rpc_name_);
ReportRequest* report = static_cast<ReportRequest*>(request_proto_.get());
- EXPECT_TRUE(report->header().has_framework_version());
+ EXPECT_EQ(kChromeVersion,
+ report->header().framework_version().version_name());
EXPECT_EQ("CreateRequestHeader App ID",
report->header().client_version().client());
EXPECT_EQ("CreateRequestHeader Device ID",
report->header().registered_device_id());
+ EXPECT_EQ(CHROME_PLATFORM_TYPE,
+ report->header().device_fingerprint().type());
}
// TODO(ckehoe): Renable these after https://codereview.chromium.org/453203002/
« components/copresence/rpc/rpc_handler.cc ('K') | « components/copresence/rpc/rpc_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698