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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "chrome/browser/extensions/app_notify_channel_setup.h" | 6 #include "chrome/browser/extensions/app_notify_channel_setup.h" |
7 #include "chrome/browser/extensions/extension_browsertest.h" | 7 #include "chrome/browser/extensions/extension_browsertest.h" |
8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
11 #include "chrome/browser/ui/extensions/application_launch.h" | 11 #include "chrome/browser/ui/extensions/application_launch.h" |
12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
13 #include "chrome/common/extensions/extension.h" | 13 #include "chrome/common/extensions/extension.h" |
14 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
16 | 16 |
17 using content::BrowserThread; | 17 using content::BrowserThread; |
18 | 18 |
19 class AppNotificationTest : public ExtensionBrowserTest {}; | 19 class AppNotificationTest : public ExtensionBrowserTest {}; |
20 | 20 |
| 21 namespace extensions { |
| 22 |
21 namespace { | 23 namespace { |
22 | 24 |
23 // Our test app will call the getNotificationChannel API using this client id. | 25 // Our test app will call the getNotificationChannel API using this client id. |
24 static const char* kExpectedClientId = "dummy_client_id"; | 26 static const char* kExpectedClientId = "dummy_client_id"; |
25 | 27 |
26 class Interceptor : public AppNotifyChannelSetup::InterceptorForTests { | 28 class Interceptor : public AppNotifyChannelSetup::InterceptorForTests { |
27 public: | 29 public: |
28 Interceptor() : was_called_(false) {} | 30 Interceptor() : was_called_(false) {} |
29 virtual ~Interceptor() {} | 31 virtual ~Interceptor() {} |
30 | 32 |
(...skipping 17 matching lines...) Expand all Loading... |
48 | 50 |
49 | 51 |
50 } // namespace | 52 } // namespace |
51 | 53 |
52 // A test that makes sure we properly save the client id we were passed when | 54 // A test that makes sure we properly save the client id we were passed when |
53 // the app called the getNotificationChannel API. | 55 // the app called the getNotificationChannel API. |
54 IN_PROC_BROWSER_TEST_F(AppNotificationTest, SaveClientId) { | 56 IN_PROC_BROWSER_TEST_F(AppNotificationTest, SaveClientId) { |
55 Interceptor interceptor; | 57 Interceptor interceptor; |
56 AppNotifyChannelSetup::SetInterceptorForTests(&interceptor); | 58 AppNotifyChannelSetup::SetInterceptorForTests(&interceptor); |
57 | 59 |
58 const extensions::Extension* app = | 60 const Extension* app = |
59 LoadExtension(test_data_dir_.AppendASCII("app_notifications")); | 61 LoadExtension(test_data_dir_.AppendASCII("app_notifications")); |
60 ASSERT_TRUE(app != NULL); | 62 ASSERT_TRUE(app != NULL); |
61 | 63 |
62 application_launch::OpenApplication(application_launch::LaunchParams( | 64 application_launch::OpenApplication(application_launch::LaunchParams( |
63 browser()->profile(), app, extension_misc::LAUNCH_TAB, | 65 browser()->profile(), app, extension_misc::LAUNCH_TAB, |
64 NEW_FOREGROUND_TAB)); | 66 NEW_FOREGROUND_TAB)); |
65 if (!interceptor.was_called()) | 67 if (!interceptor.was_called()) |
66 content::RunMessageLoop(); | 68 content::RunMessageLoop(); |
67 EXPECT_TRUE(interceptor.was_called()); | 69 EXPECT_TRUE(interceptor.was_called()); |
68 | 70 |
69 ExtensionService* service = browser()->profile()->GetExtensionService(); | 71 ExtensionService* service = browser()->profile()->GetExtensionService(); |
70 extensions::ExtensionPrefs* prefs = service->extension_prefs(); | 72 ExtensionPrefs* prefs = service->extension_prefs(); |
71 std::string saved_id = prefs->GetAppNotificationClientId(app->id()); | 73 std::string saved_id = prefs->GetAppNotificationClientId(app->id()); |
72 EXPECT_EQ(kExpectedClientId, saved_id); | 74 EXPECT_EQ(kExpectedClientId, saved_id); |
73 } | 75 } |
| 76 |
| 77 } // namespace extensions |
OLD | NEW |