| 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 "base/json/json_reader.h" | 5 #include "base/json/json_reader.h" |
| 6 #include "base/json/json_writer.h" | 6 #include "base/json/json_writer.h" |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 } | 835 } |
| 836 | 836 |
| 837 protected: | 837 protected: |
| 838 content::TestBrowserThreadBundle thread_bundle_; | 838 content::TestBrowserThreadBundle thread_bundle_; |
| 839 scoped_ptr<WalletClient> wallet_client_; | 839 scoped_ptr<WalletClient> wallet_client_; |
| 840 TestingProfile browser_context_; | 840 TestingProfile browser_context_; |
| 841 MockWalletClientDelegate delegate_; | 841 MockWalletClientDelegate delegate_; |
| 842 | 842 |
| 843 private: | 843 private: |
| 844 std::string GetData(const std::string& upload_data) { | 844 std::string GetData(const std::string& upload_data) { |
| 845 scoped_ptr<Value> root(base::JSONReader::Read(upload_data)); | 845 scoped_ptr<base::Value> root(base::JSONReader::Read(upload_data)); |
| 846 | 846 |
| 847 // If this is not a JSON dictionary, return plain text. | 847 // If this is not a JSON dictionary, return plain text. |
| 848 if (!root || !root->IsType(Value::TYPE_DICTIONARY)) | 848 if (!root || !root->IsType(base::Value::TYPE_DICTIONARY)) |
| 849 return upload_data; | 849 return upload_data; |
| 850 | 850 |
| 851 // Remove api_key entry (to prevent accidental leak), return JSON as text. | 851 // Remove api_key entry (to prevent accidental leak), return JSON as text. |
| 852 DictionaryValue* dict = static_cast<DictionaryValue*>(root.get()); | 852 base::DictionaryValue* dict = |
| 853 static_cast<base::DictionaryValue*>(root.get()); |
| 853 dict->Remove("api_key", NULL); | 854 dict->Remove("api_key", NULL); |
| 854 std::string clean_upload_data; | 855 std::string clean_upload_data; |
| 855 base::JSONWriter::Write(dict, &clean_upload_data); | 856 base::JSONWriter::Write(dict, &clean_upload_data); |
| 856 return clean_upload_data; | 857 return clean_upload_data; |
| 857 } | 858 } |
| 858 | 859 |
| 859 net::TestURLFetcherFactory factory_; | 860 net::TestURLFetcherFactory factory_; |
| 860 }; | 861 }; |
| 861 | 862 |
| 862 TEST_F(WalletClientTest, WalletErrorCodes) { | 863 TEST_F(WalletClientTest, WalletErrorCodes) { |
| (...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1746 wallet_client_->GetWalletItems(); | 1747 wallet_client_->GetWalletItems(); |
| 1747 EXPECT_EQ(2U, wallet_client_->pending_requests_.size()); | 1748 EXPECT_EQ(2U, wallet_client_->pending_requests_.size()); |
| 1748 | 1749 |
| 1749 wallet_client_->CancelRequests(); | 1750 wallet_client_->CancelRequests(); |
| 1750 EXPECT_EQ(0U, wallet_client_->pending_requests_.size()); | 1751 EXPECT_EQ(0U, wallet_client_->pending_requests_.size()); |
| 1751 EXPECT_FALSE(wallet_client_->HasRequestInProgress()); | 1752 EXPECT_FALSE(wallet_client_->HasRequestInProgress()); |
| 1752 } | 1753 } |
| 1753 | 1754 |
| 1754 } // namespace wallet | 1755 } // namespace wallet |
| 1755 } // namespace autofill | 1756 } // namespace autofill |
| OLD | NEW |