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

Side by Side Diff: chrome/browser/net/gaia/token_service_unittest.cc

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 // This file defines a unit test for the profile's token service. 5 // This file defines a unit test for the profile's token service.
6 6
7 #include "chrome/browser/net/gaia/token_service_unittest.h" 7 #include "chrome/browser/net/gaia/token_service_unittest.h"
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
11 #include "chrome/browser/password_manager/encryptor.h" 11 #include "chrome/browser/password_manager/encryptor.h"
12 #include "chrome/common/chrome_notification_types.h"
12 #include "chrome/common/chrome_switches.h" 13 #include "chrome/common/chrome_switches.h"
13 #include "chrome/common/net/gaia/gaia_auth_fetcher_unittest.h" 14 #include "chrome/common/net/gaia/gaia_auth_fetcher_unittest.h"
14 #include "chrome/common/net/gaia/gaia_constants.h" 15 #include "chrome/common/net/gaia/gaia_constants.h"
15 #include "content/common/test_url_fetcher_factory.h" 16 #include "content/common/test_url_fetcher_factory.h"
16 17
17 TokenAvailableTracker::TokenAvailableTracker() {} 18 TokenAvailableTracker::TokenAvailableTracker() {}
18 19
19 TokenAvailableTracker::~TokenAvailableTracker() {} 20 TokenAvailableTracker::~TokenAvailableTracker() {}
20 21
21 void TokenAvailableTracker::Observe(NotificationType type, 22 void TokenAvailableTracker::Observe(int type,
22 const NotificationSource& source, 23 const NotificationSource& source,
23 const NotificationDetails& details) { 24 const NotificationDetails& details) {
24 TestNotificationTracker::Observe(type, source, details); 25 TestNotificationTracker::Observe(type, source, details);
25 if (type == NotificationType::TOKEN_AVAILABLE) { 26 if (type == chrome::NOTIFICATION_TOKEN_AVAILABLE) {
26 Details<const TokenService::TokenAvailableDetails> full = details; 27 Details<const TokenService::TokenAvailableDetails> full = details;
27 details_ = *full.ptr(); 28 details_ = *full.ptr();
28 } 29 }
29 } 30 }
30 31
31 TokenFailedTracker::TokenFailedTracker() {} 32 TokenFailedTracker::TokenFailedTracker() {}
32 33
33 TokenFailedTracker::~TokenFailedTracker() {} 34 TokenFailedTracker::~TokenFailedTracker() {}
34 35
35 void TokenFailedTracker::Observe(NotificationType type, 36 void TokenFailedTracker::Observe(int type,
36 const NotificationSource& source, 37 const NotificationSource& source,
37 const NotificationDetails& details) { 38 const NotificationDetails& details) {
38 TestNotificationTracker::Observe(type, source, details); 39 TestNotificationTracker::Observe(type, source, details);
39 if (type == NotificationType::TOKEN_REQUEST_FAILED) { 40 if (type == chrome::NOTIFICATION_TOKEN_REQUEST_FAILED) {
40 Details<const TokenService::TokenRequestFailedDetails> full = details; 41 Details<const TokenService::TokenRequestFailedDetails> full = details;
41 details_ = *full.ptr(); 42 details_ = *full.ptr();
42 } 43 }
43 } 44 }
44 45
45 TokenServiceTestHarness::TokenServiceTestHarness() 46 TokenServiceTestHarness::TokenServiceTestHarness()
46 : ui_thread_(BrowserThread::UI, &message_loop_), 47 : ui_thread_(BrowserThread::UI, &message_loop_),
47 db_thread_(BrowserThread::DB) { 48 db_thread_(BrowserThread::DB) {
48 } 49 }
49 50
50 TokenServiceTestHarness::~TokenServiceTestHarness() {} 51 TokenServiceTestHarness::~TokenServiceTestHarness() {}
51 52
52 void TokenServiceTestHarness::SetUp() { 53 void TokenServiceTestHarness::SetUp() {
53 #if defined(OS_MACOSX) 54 #if defined(OS_MACOSX)
54 Encryptor::UseMockKeychain(true); 55 Encryptor::UseMockKeychain(true);
55 #endif 56 #endif
56 credentials_.sid = "sid"; 57 credentials_.sid = "sid";
57 credentials_.lsid = "lsid"; 58 credentials_.lsid = "lsid";
58 credentials_.token = "token"; 59 credentials_.token = "token";
59 credentials_.data = "data"; 60 credentials_.data = "data";
60 61
61 ASSERT_TRUE(db_thread_.Start()); 62 ASSERT_TRUE(db_thread_.Start());
62 63
63 profile_.reset(new TestingProfile()); 64 profile_.reset(new TestingProfile());
64 profile_->CreateWebDataService(false); 65 profile_->CreateWebDataService(false);
65 WaitForDBLoadCompletion(); 66 WaitForDBLoadCompletion();
66 67
67 success_tracker_.ListenFor(NotificationType::TOKEN_AVAILABLE, 68 success_tracker_.ListenFor(chrome::NOTIFICATION_TOKEN_AVAILABLE,
68 Source<TokenService>(&service_)); 69 Source<TokenService>(&service_));
69 failure_tracker_.ListenFor(NotificationType::TOKEN_REQUEST_FAILED, 70 failure_tracker_.ListenFor(chrome::NOTIFICATION_TOKEN_REQUEST_FAILED,
70 Source<TokenService>(&service_)); 71 Source<TokenService>(&service_));
71 72
72 service_.Initialize("test", profile_.get()); 73 service_.Initialize("test", profile_.get());
73 74
74 URLFetcher::set_factory(NULL); 75 URLFetcher::set_factory(NULL);
75 } 76 }
76 77
77 void TokenServiceTestHarness::TearDown() { 78 void TokenServiceTestHarness::TearDown() {
78 // You have to destroy the profile before the db_thread_ stops. 79 // You have to destroy the profile before the db_thread_ stops.
79 if (profile_.get()) { 80 if (profile_.get()) {
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 358
358 *CommandLine::ForCurrentProcess() = original_cl; 359 *CommandLine::ForCurrentProcess() = original_cl;
359 } 360 }
360 }; 361 };
361 362
362 TEST_F(TokenServiceCommandLineTest, TestValueOverride) { 363 TEST_F(TokenServiceCommandLineTest, TestValueOverride) {
363 EXPECT_TRUE(service_.HasTokenForService("my_service")); 364 EXPECT_TRUE(service_.HasTokenForService("my_service"));
364 EXPECT_EQ("my_value", service_.GetTokenForService("my_service")); 365 EXPECT_EQ("my_value", service_.GetTokenForService("my_service"));
365 } 366 }
366 #endif // ifndef NDEBUG 367 #endif // ifndef NDEBUG
OLDNEW
« no previous file with comments | « chrome/browser/net/gaia/token_service_unittest.h ('k') | chrome/browser/net/net_pref_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698