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

Unified Diff: components/cryptauth/cryptauth_client_impl_unittest.cc

Issue 2888053003: Network traffic annotation added to OAuth2ApiCallFlow and its subclasses. (Closed)
Patch Set: Annotations updated. Created 3 years, 6 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
« no previous file with comments | « components/cryptauth/cryptauth_client_impl.cc ('k') | components/cryptauth/cryptauth_device_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/cryptauth/cryptauth_client_impl_unittest.cc
diff --git a/components/cryptauth/cryptauth_client_impl_unittest.cc b/components/cryptauth/cryptauth_client_impl_unittest.cc
index 20224c002950045b539eb27c67b0fa9814d493a0..4a012ec05045b0cea98f19d74c70fb7a05ff90c0 100644
--- a/components/cryptauth/cryptauth_client_impl_unittest.cc
+++ b/components/cryptauth/cryptauth_client_impl_unittest.cc
@@ -13,6 +13,7 @@
#include "components/cryptauth/proto/cryptauth_api.pb.h"
#include "components/cryptauth/switches.h"
#include "google_apis/gaia/fake_oauth2_token_service.h"
+#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "net/url_request/test_url_fetcher_factory.h"
#include "net/url_request/url_request_test_util.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -63,7 +64,9 @@ class FakeCryptAuthAccessTokenFetcher : public CryptAuthAccessTokenFetcher {
// Mock CryptAuthApiCallFlow, which handles the HTTP requests to CryptAuth.
class MockCryptAuthApiCallFlow : public CryptAuthApiCallFlow {
public:
- MockCryptAuthApiCallFlow() : CryptAuthApiCallFlow() {}
+ MockCryptAuthApiCallFlow() : CryptAuthApiCallFlow() {
+ SetPartialNetworkTrafficAnnotation(PARTIAL_TRAFFIC_ANNOTATION_FOR_TESTS);
+ }
virtual ~MockCryptAuthApiCallFlow() {}
MOCK_METHOD6(Start,
@@ -166,7 +169,8 @@ TEST_F(CryptAuthClientTest, GetMyDevicesSuccess) {
client_->GetMyDevices(
request_proto,
base::Bind(&SaveResult<GetMyDevicesResponse>, &result_proto),
- base::Bind(&NotCalled<std::string>));
+ base::Bind(&NotCalled<std::string>),
+ PARTIAL_TRAFFIC_ANNOTATION_FOR_TESTS);
GetMyDevicesRequest expected_request;
EXPECT_TRUE(expected_request.ParseFromString(serialized_request_));
@@ -203,7 +207,8 @@ TEST_F(CryptAuthClientTest, GetMyDevicesFailure) {
std::string error_message;
client_->GetMyDevices(GetMyDevicesRequest(),
base::Bind(&NotCalled<GetMyDevicesResponse>),
- base::Bind(&SaveResult<std::string>, &error_message));
+ base::Bind(&SaveResult<std::string>, &error_message),
+ PARTIAL_TRAFFIC_ANNOTATION_FOR_TESTS);
std::string kStatus500Error("HTTP status: 500");
FailApiCallFlow(kStatus500Error);
@@ -279,9 +284,9 @@ TEST_F(CryptAuthClientTest, SendDeviceSyncTickleSuccess) {
SendDeviceSyncTickleResponse result_proto;
client_->SendDeviceSyncTickle(
SendDeviceSyncTickleRequest(),
- base::Bind(&SaveResult<SendDeviceSyncTickleResponse>,
- &result_proto),
- base::Bind(&NotCalled<std::string>));
+ base::Bind(&SaveResult<SendDeviceSyncTickleResponse>, &result_proto),
+ base::Bind(&NotCalled<std::string>),
+ PARTIAL_TRAFFIC_ANNOTATION_FOR_TESTS);
SendDeviceSyncTickleRequest expected_request;
EXPECT_TRUE(expected_request.ParseFromString(serialized_request_));
@@ -401,7 +406,8 @@ TEST_F(CryptAuthClientTest, FetchAccessTokenFailure) {
std::string error_message;
client_->GetMyDevices(GetMyDevicesRequest(),
base::Bind(&NotCalled<GetMyDevicesResponse>),
- base::Bind(&SaveResult<std::string>, &error_message));
+ base::Bind(&SaveResult<std::string>, &error_message),
+ PARTIAL_TRAFFIC_ANNOTATION_FOR_TESTS);
EXPECT_EQ("Failed to get a valid access token.", error_message);
}
@@ -414,7 +420,8 @@ TEST_F(CryptAuthClientTest, ParseResponseProtoFailure) {
std::string error_message;
client_->GetMyDevices(GetMyDevicesRequest(),
base::Bind(&NotCalled<GetMyDevicesResponse>),
- base::Bind(&SaveResult<std::string>, &error_message));
+ base::Bind(&SaveResult<std::string>, &error_message),
+ PARTIAL_TRAFFIC_ANNOTATION_FOR_TESTS);
flow_result_callback_.Run("Not a valid serialized response message.");
EXPECT_EQ("Failed to parse response proto.", error_message);
@@ -431,7 +438,8 @@ TEST_F(CryptAuthClientTest,
client_->GetMyDevices(
GetMyDevicesRequest(),
base::Bind(&SaveResult<GetMyDevicesResponse>, &result_proto),
- base::Bind(&NotCalled<std::string>));
+ base::Bind(&NotCalled<std::string>),
+ PARTIAL_TRAFFIC_ANNOTATION_FOR_TESTS);
// With request pending, make second request.
{
@@ -466,7 +474,8 @@ TEST_F(CryptAuthClientTest,
std::string error_message;
client_->GetMyDevices(GetMyDevicesRequest(),
base::Bind(&NotCalled<GetMyDevicesResponse>),
- base::Bind(&SaveResult<std::string>, &error_message));
+ base::Bind(&SaveResult<std::string>, &error_message),
+ PARTIAL_TRAFFIC_ANNOTATION_FOR_TESTS);
// With request pending, make second request.
{
@@ -496,7 +505,8 @@ TEST_F(CryptAuthClientTest,
client_->GetMyDevices(
GetMyDevicesRequest(),
base::Bind(&SaveResult<GetMyDevicesResponse>, &result_proto),
- base::Bind(&NotCalled<std::string>));
+ base::Bind(&NotCalled<std::string>),
+ PARTIAL_TRAFFIC_ANNOTATION_FOR_TESTS);
GetMyDevicesResponse response_proto;
response_proto.add_devices();
@@ -529,7 +539,8 @@ TEST_F(CryptAuthClientTest, DeviceClassifierIsSet) {
client_->GetMyDevices(
request_proto,
base::Bind(&SaveResult<GetMyDevicesResponse>, &result_proto),
- base::Bind(&NotCalled<std::string>));
+ base::Bind(&NotCalled<std::string>),
+ PARTIAL_TRAFFIC_ANNOTATION_FOR_TESTS);
GetMyDevicesRequest expected_request;
EXPECT_TRUE(expected_request.ParseFromString(serialized_request_));
@@ -555,7 +566,8 @@ TEST_F(CryptAuthClientTest, GetAccessTokenUsed) {
client_->GetMyDevices(
request_proto,
base::Bind(&SaveResult<GetMyDevicesResponse>, &result_proto),
- base::Bind(&NotCalled<std::string>));
+ base::Bind(&NotCalled<std::string>),
+ PARTIAL_TRAFFIC_ANNOTATION_FOR_TESTS);
EXPECT_EQ(kAccessToken, client_->GetAccessTokenUsed());
}
« no previous file with comments | « components/cryptauth/cryptauth_client_impl.cc ('k') | components/cryptauth/cryptauth_device_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698