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