| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_DESKTOP_NOTIFICATIONS_UNITTEST_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_DESKTOP_NOTIFICATIONS_UNITTEST_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <set> | |
| 10 #include <string> | |
| 11 | |
| 12 #include "base/compiler_specific.h" | |
| 13 #include "base/message_loop.h" | |
| 14 #include "base/string_util.h" | |
| 15 #include "chrome/browser/chromeos/cros/cros_library.h" | |
| 16 #include "chrome/browser/notifications/balloon.h" | |
| 17 #include "chrome/browser/notifications/desktop_notification_service.h" | |
| 18 #include "chrome/browser/notifications/notification.h" | |
| 19 #include "chrome/browser/notifications/notification_test_util.h" | |
| 20 #include "chrome/browser/notifications/notification_ui_manager.h" | |
| 21 #include "chrome/browser/ui/browser_list.h" | |
| 22 #include "chrome/test/base/testing_pref_service.h" | |
| 23 #include "chrome/test/base/testing_profile.h" | |
| 24 #include "content/test/test_browser_thread.h" | |
| 25 #include "testing/gtest/include/gtest/gtest.h" | |
| 26 | |
| 27 namespace content { | |
| 28 struct ShowDesktopNotificationHostMsgParams; | |
| 29 } | |
| 30 | |
| 31 namespace chromeos { | |
| 32 | |
| 33 class DesktopNotificationsTest; | |
| 34 class MockBalloonCollection; | |
| 35 | |
| 36 class DesktopNotificationsTest : public testing::Test { | |
| 37 public: | |
| 38 DesktopNotificationsTest(); | |
| 39 virtual ~DesktopNotificationsTest(); | |
| 40 | |
| 41 static void log(const std::string& message) { | |
| 42 log_output_.append(message); | |
| 43 } | |
| 44 | |
| 45 Profile* profile() { return profile_.get(); } | |
| 46 | |
| 47 protected: | |
| 48 // testing::Test overrides | |
| 49 virtual void SetUp() OVERRIDE; | |
| 50 virtual void TearDown() OVERRIDE; | |
| 51 | |
| 52 void AllowOrigin(const GURL& origin) { | |
| 53 service_->GrantPermission(origin); | |
| 54 } | |
| 55 | |
| 56 void DenyOrigin(const GURL& origin) { | |
| 57 service_->DenyPermission(origin); | |
| 58 } | |
| 59 | |
| 60 int HasPermission(const GURL& origin) { | |
| 61 return service_->HasPermission(origin); | |
| 62 } | |
| 63 | |
| 64 // Constructs a notification parameter structure for use in tests. | |
| 65 content::ShowDesktopNotificationHostMsgParams StandardTestNotification(); | |
| 66 | |
| 67 // Create a message loop to allow notifications code to post tasks, | |
| 68 // and a thread so that notifications code runs on the expected thread. | |
| 69 MessageLoopForUI message_loop_; | |
| 70 content::TestBrowserThread ui_thread_; | |
| 71 | |
| 72 // Mock local state. | |
| 73 TestingPrefService local_state_; | |
| 74 | |
| 75 // Test profile. | |
| 76 scoped_ptr<TestingProfile> profile_; | |
| 77 | |
| 78 // Mock balloon collection -- owned by the NotificationUIManager | |
| 79 MockBalloonCollection* balloon_collection_; | |
| 80 | |
| 81 // Real UI manager. | |
| 82 scoped_ptr<NotificationUIManager> ui_manager_; | |
| 83 | |
| 84 // Real DesktopNotificationService | |
| 85 scoped_ptr<DesktopNotificationService> service_; | |
| 86 | |
| 87 // Contains the cumulative output of the unit test. | |
| 88 static std::string log_output_; | |
| 89 | |
| 90 // Initializes / shuts down a stub CrosLibrary. | |
| 91 chromeos::ScopedStubCrosEnabler stub_cros_enabler_; | |
| 92 }; | |
| 93 | |
| 94 } // namespace chromeos | |
| 95 | |
| 96 #endif // CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_DESKTOP_NOTIFICATIONS_UNITTEST_
H_ | |
| OLD | NEW |