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

Unified Diff: chrome/browser/net/gaia/authentication_service_unittest.h

Issue 6894027: Initial refactoring complete Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fixed some tests that were broken by previous refactoring Created 9 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/net/gaia/authentication_service_unittest.h
diff --git a/chrome/browser/net/gaia/authentication_service_unittest.h b/chrome/browser/net/gaia/authentication_service_unittest.h
new file mode 100644
index 0000000000000000000000000000000000000000..5663f82a9cb0bb33c9dcaca523ecf4f734519e14
--- /dev/null
+++ b/chrome/browser/net/gaia/authentication_service_unittest.h
@@ -0,0 +1,81 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// This file defines a unit test harness for the profile's token service.
+
+#ifndef CHROME_BROWSER_NET_GAIA_AUTHENTICATION_SERVICE_UNITTEST_H_
+#define CHROME_BROWSER_NET_GAIA_AUTHENTICATION_SERVICE_UNITTEST_H_
+#pragma once
+
+#include "base/synchronization/waitable_event.h"
+#include "chrome/browser/net/gaia/token_service.h"
+#include "chrome/browser/webdata/web_data_service.h"
+#include "chrome/common/net/gaia/gaia_auth_consumer.h"
+#include "chrome/test/signaling_task.h"
+#include "chrome/test/test_notification_tracker.h"
+#include "chrome/test/testing_profile.h"
+#include "content/common/notification_details.h"
+#include "content/common/notification_source.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+// TestNotificationTracker doesn't do a deep copy on the notification details.
+// We have to in order to read it out, or we have a bad ptr, since the details
+// are a reference on the stack.
+class TokenAvailableTracker : public TestNotificationTracker {
+ public:
+ TokenAvailableTracker();
+ virtual ~TokenAvailableTracker();
+
+ const AuthenticationService::TokenAvailableDetails& details() {
+ return details_;
+ }
+
+ private:
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
+
+ AuthenticationService::TokenAvailableDetails details_;
+};
+
+class TokenFailedTracker : public TestNotificationTracker {
+ public:
+ TokenFailedTracker();
+ virtual ~TokenFailedTracker();
+
+ const AuthenticationService::TokenRequestFailedDetails& details() {
+ return details_;
+ }
+
+ private:
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
+
+ AuthenticationService::TokenRequestFailedDetails details_;
+};
+
+class AuthenticationServiceTestHarness : public testing::Test {
+ public:
+ AuthenticationServiceTestHarness();
+ virtual ~AuthenticationServiceTestHarness();
+
+ virtual void SetUp();
+
+ virtual void TearDown();
+
+ void WaitForDBLoadCompletion();
+
+ MessageLoopForUI message_loop_;
+ BrowserThread ui_thread_; // Mostly so DCHECKS pass.
+ BrowserThread db_thread_; // WDS on here
+
+ AuthenticationService service_;
+ TokenAvailableTracker success_tracker_;
+ TokenFailedTracker failure_tracker_;
+ GaiaAuthConsumer::ClientLoginResult credentials_;
+ scoped_ptr<TestingProfile> profile_;
+};
+
+#endif // CHROME_BROWSER_NET_GAIA_AUTHENTICATION_SERVICE_UNITTEST_H_
« no previous file with comments | « chrome/browser/net/gaia/authentication_service.cc ('k') | chrome/browser/net/gaia/authentication_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698