| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "sync/test/accounts_client/test_accounts_client.h" | 9 #include "sync/test/accounts_client/test_accounts_client.h" |
| 10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 usernames.push_back("foo2@gmail.com"); | 60 usernames.push_back("foo2@gmail.com"); |
| 61 NoNetworkTestAccountsClient client(kServer, kAccountSpace, usernames); | 61 NoNetworkTestAccountsClient client(kServer, kAccountSpace, usernames); |
| 62 | 62 |
| 63 base::DictionaryValue success_dict; | 63 base::DictionaryValue success_dict; |
| 64 success_dict.Set("username", new base::StringValue(kUsername)); | 64 success_dict.Set("username", new base::StringValue(kUsername)); |
| 65 success_dict.Set("account_space", new base::StringValue(kAccountSpace)); | 65 success_dict.Set("account_space", new base::StringValue(kAccountSpace)); |
| 66 success_dict.Set("session_id", new base::StringValue(kSessionId)); | 66 success_dict.Set("session_id", new base::StringValue(kSessionId)); |
| 67 success_dict.Set("expiration_time", new base::StringValue(kExpirationTime)); | 67 success_dict.Set("expiration_time", new base::StringValue(kExpirationTime)); |
| 68 | 68 |
| 69 string success_response; | 69 string success_response; |
| 70 base::JSONWriter::Write(&success_dict, &success_response); | 70 base::JSONWriter::Write(success_dict, &success_response); |
| 71 EXPECT_CALL(client, SendRequest(_, _)) | 71 EXPECT_CALL(client, SendRequest(_, _)) |
| 72 .WillOnce(DoAll(SetArgPointee<1>(success_response), Return(true))); | 72 .WillOnce(DoAll(SetArgPointee<1>(success_response), Return(true))); |
| 73 | 73 |
| 74 AccountSession session; | 74 AccountSession session; |
| 75 EXPECT_TRUE(client.ClaimAccount(&session)); | 75 EXPECT_TRUE(client.ClaimAccount(&session)); |
| 76 EXPECT_EQ(kUsername, session.username); | 76 EXPECT_EQ(kUsername, session.username); |
| 77 EXPECT_EQ(kAccountSpace, session.account_space); | 77 EXPECT_EQ(kAccountSpace, session.account_space); |
| 78 EXPECT_EQ(kSessionId, session.session_id); | 78 EXPECT_EQ(kSessionId, session.session_id); |
| 79 EXPECT_EQ(kExpirationTime, session.expiration_time); | 79 EXPECT_EQ(kExpirationTime, session.expiration_time); |
| 80 } | 80 } |
| 81 | 81 |
| 82 TEST(TestAccountsClientTest, ReleaseAccountEmptySession) { | 82 TEST(TestAccountsClientTest, ReleaseAccountEmptySession) { |
| 83 vector<string> usernames; | 83 vector<string> usernames; |
| 84 NoNetworkTestAccountsClient client(kServer, kAccountSpace, usernames); | 84 NoNetworkTestAccountsClient client(kServer, kAccountSpace, usernames); |
| 85 AccountSession session; | 85 AccountSession session; |
| 86 // No expectation for SendRequest is made because no network call should be | 86 // No expectation for SendRequest is made because no network call should be |
| 87 // performed in this scenario. | 87 // performed in this scenario. |
| 88 client.ReleaseAccount(session); | 88 client.ReleaseAccount(session); |
| 89 } | 89 } |
| 90 | 90 |
| 91 TEST(TestAccountsClientTest, ReleaseAccountSuccess) { | 91 TEST(TestAccountsClientTest, ReleaseAccountSuccess) { |
| 92 vector<string> usernames; | 92 vector<string> usernames; |
| 93 NoNetworkTestAccountsClient client(kServer, kAccountSpace, usernames); | 93 NoNetworkTestAccountsClient client(kServer, kAccountSpace, usernames); |
| 94 EXPECT_CALL(client, SendRequest(_, _)) | 94 EXPECT_CALL(client, SendRequest(_, _)) |
| 95 .WillOnce(Return(true)); | 95 .WillOnce(Return(true)); |
| 96 AccountSession session = CreateValidAccountSession(); | 96 AccountSession session = CreateValidAccountSession(); |
| 97 client.ReleaseAccount(session); | 97 client.ReleaseAccount(session); |
| 98 } | 98 } |
| OLD | NEW |