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

Side by Side Diff: chrome/browser/extensions/app_notification_browsertest.cc

Issue 12680004: Remove chrome/ code to handle App Notifications (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix merge conflicts. Created 7 years, 9 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
(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 #include "base/command_line.h"
6 #include "chrome/browser/extensions/app_notify_channel_setup.h"
7 #include "chrome/browser/extensions/extension_browsertest.h"
8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/extensions/extension_system.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/extensions/application_launch.h"
13 #include "chrome/common/chrome_switches.h"
14 #include "chrome/common/extensions/extension.h"
15 #include "chrome/test/base/ui_test_utils.h"
16 #include "content/public/browser/browser_thread.h"
17
18 using content::BrowserThread;
19
20 class AppNotificationTest : public ExtensionBrowserTest {};
21
22 namespace extensions {
23
24 namespace {
25
26 // Our test app will call the getNotificationChannel API using this client id.
27 static const char* kExpectedClientId = "dummy_client_id";
28
29 class Interceptor : public AppNotifyChannelSetup::InterceptorForTests {
30 public:
31 Interceptor() : was_called_(false) {}
32 virtual ~Interceptor() {}
33
34 virtual void DoIntercept(
35 const AppNotifyChannelSetup* setup,
36 std::string* result_channel_id,
37 AppNotifyChannelSetup::SetupError* result_error) OVERRIDE {
38 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI));
39 EXPECT_TRUE(setup->client_id() == std::string(kExpectedClientId));
40 *result_channel_id = std::string("1234");
41 *result_error = AppNotifyChannelSetup::NONE;
42 was_called_ = true;
43 MessageLoop::current()->Quit();
44 }
45
46 bool was_called() const { return was_called_; }
47
48 private:
49 bool was_called_;
50 };
51
52
53 } // namespace
54
55 // A test that makes sure we properly save the client id we were passed when
56 // the app called the getNotificationChannel API.
57 IN_PROC_BROWSER_TEST_F(AppNotificationTest, SaveClientId) {
58 Interceptor interceptor;
59 AppNotifyChannelSetup::SetInterceptorForTests(&interceptor);
60
61 const Extension* app =
62 LoadExtension(test_data_dir_.AppendASCII("app_notifications"));
63 ASSERT_TRUE(app != NULL);
64
65 chrome::OpenApplication(chrome::AppLaunchParams(browser()->profile(), app,
66 extension_misc::LAUNCH_TAB,
67 NEW_FOREGROUND_TAB));
68 if (!interceptor.was_called())
69 content::RunMessageLoop();
70 EXPECT_TRUE(interceptor.was_called());
71
72 ExtensionService* service = extensions::ExtensionSystem::Get(
73 browser()->profile())->extension_service();
74 ExtensionPrefs* prefs = service->extension_prefs();
75 std::string saved_id = prefs->GetAppNotificationClientId(app->id());
76 EXPECT_EQ(kExpectedClientId, saved_id);
77 }
78
79 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/app_notification.cc ('k') | chrome/browser/extensions/app_notification_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698