OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <map> | 5 #include <map> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 #include "chromeos/dbus/fake_dbus_thread_manager.h" | 49 #include "chromeos/dbus/fake_dbus_thread_manager.h" |
50 #include "chromeos/dbus/fake_session_manager_client.h" | 50 #include "chromeos/dbus/fake_session_manager_client.h" |
51 #include "chromeos/dbus/session_manager_client.h" | 51 #include "chromeos/dbus/session_manager_client.h" |
52 #include "components/policy/core/common/cloud/cloud_policy_core.h" | 52 #include "components/policy/core/common/cloud/cloud_policy_core.h" |
53 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 53 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
54 #include "components/policy/core/common/cloud/policy_builder.h" | 54 #include "components/policy/core/common/cloud/policy_builder.h" |
55 #include "content/public/browser/notification_service.h" | 55 #include "content/public/browser/notification_service.h" |
56 #include "content/public/browser/notification_source.h" | 56 #include "content/public/browser/notification_source.h" |
57 #include "content/public/test/test_utils.h" | 57 #include "content/public/test/test_utils.h" |
58 #include "crypto/rsa_private_key.h" | 58 #include "crypto/rsa_private_key.h" |
| 59 #include "google_apis/gaia/gaia_oauth_client.h" |
59 #include "google_apis/gaia/oauth2_token_service.h" | 60 #include "google_apis/gaia/oauth2_token_service.h" |
60 #include "net/test/embedded_test_server/embedded_test_server.h" | 61 #include "net/test/embedded_test_server/embedded_test_server.h" |
61 #include "net/url_request/test_url_fetcher_factory.h" | 62 #include "net/url_request/test_url_fetcher_factory.h" |
62 #include "net/url_request/url_fetcher_delegate.h" | 63 #include "net/url_request/url_fetcher_delegate.h" |
63 #include "net/url_request/url_request_status.h" | 64 #include "net/url_request/url_request_status.h" |
64 #include "policy/proto/cloud_policy.pb.h" | 65 #include "policy/proto/cloud_policy.pb.h" |
65 #include "testing/gtest/include/gtest/gtest.h" | 66 #include "testing/gtest/include/gtest/gtest.h" |
66 #include "third_party/skia/include/core/SkBitmap.h" | 67 #include "third_party/skia/include/core/SkBitmap.h" |
67 #include "ui/base/layout.h" | 68 #include "ui/base/layout.h" |
68 #include "ui/base/resource/resource_bundle.h" | 69 #include "ui/base/resource/resource_bundle.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 const std::string& username, | 223 const std::string& username, |
223 net::TestURLFetcherFactory* url_fetcher_factory) { | 224 net::TestURLFetcherFactory* url_fetcher_factory) { |
224 ProfileDownloader* profile_downloader = | 225 ProfileDownloader* profile_downloader = |
225 reinterpret_cast<UserImageManagerImpl*>( | 226 reinterpret_cast<UserImageManagerImpl*>( |
226 UserManager::Get()->GetUserImageManager(username))-> | 227 UserManager::Get()->GetUserImageManager(username))-> |
227 profile_downloader_.get(); | 228 profile_downloader_.get(); |
228 ASSERT_TRUE(profile_downloader); | 229 ASSERT_TRUE(profile_downloader); |
229 | 230 |
230 static_cast<OAuth2TokenService::Consumer*>(profile_downloader)-> | 231 static_cast<OAuth2TokenService::Consumer*>(profile_downloader)-> |
231 OnGetTokenSuccess(NULL, | 232 OnGetTokenSuccess(NULL, |
232 std::string(), | 233 "token", |
233 base::Time::Now() + base::TimeDelta::FromDays(1)); | 234 base::Time::Now() + base::TimeDelta::FromDays(1)); |
234 | 235 |
235 net::TestURLFetcher* fetcher = url_fetcher_factory->GetFetcherByID(0); | 236 net::TestURLFetcher* fetcher = |
| 237 url_fetcher_factory->GetFetcherByID( |
| 238 gaia::GaiaOAuthClient::kUrlFetcherId); |
236 ASSERT_TRUE(fetcher); | 239 ASSERT_TRUE(fetcher); |
237 fetcher->SetResponseString( | 240 fetcher->SetResponseString( |
238 "{ \"picture\": \"http://localhost/avatar.jpg\" }"); | 241 "{ \"image\": {\"url\": \"http://localhost/avatar.jpg\"} }"); |
239 fetcher->set_status(net::URLRequestStatus(net::URLRequestStatus::SUCCESS, | 242 fetcher->set_status(net::URLRequestStatus(net::URLRequestStatus::SUCCESS, |
240 net::OK)); | 243 net::OK)); |
241 fetcher->set_response_code(200); | 244 fetcher->set_response_code(200); |
242 fetcher->delegate()->OnURLFetchComplete(fetcher); | 245 fetcher->delegate()->OnURLFetchComplete(fetcher); |
243 base::RunLoop().RunUntilIdle(); | 246 base::RunLoop().RunUntilIdle(); |
244 } | 247 } |
245 | 248 |
246 // Completes the download of the currently logged-in user's profile image. | 249 // Completes the download of the currently logged-in user's profile image. |
247 // This method must only be called after a profile data download including | 250 // This method must only be called after a profile data download including |
248 // the profile image has been started, the download of all non-image data has | 251 // the profile image has been started, the download of all non-image data has |
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 | 856 |
854 saved_image = test::ImageLoader(GetUserImagePath(kTestUser1, "jpg")).Load(); | 857 saved_image = test::ImageLoader(GetUserImagePath(kTestUser1, "jpg")).Load(); |
855 ASSERT_TRUE(saved_image); | 858 ASSERT_TRUE(saved_image); |
856 | 859 |
857 // Check image dimensions. Images can't be compared since JPEG is lossy. | 860 // Check image dimensions. Images can't be compared since JPEG is lossy. |
858 EXPECT_EQ(policy_image_->width(), saved_image->width()); | 861 EXPECT_EQ(policy_image_->width(), saved_image->width()); |
859 EXPECT_EQ(policy_image_->height(), saved_image->height()); | 862 EXPECT_EQ(policy_image_->height(), saved_image->height()); |
860 } | 863 } |
861 | 864 |
862 } // namespace chromeos | 865 } // namespace chromeos |
OLD | NEW |