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

Unified Diff: chrome/browser/extensions/app_notification_browsertest.cc

Issue 8727024: Save the oauth client id used in App Notification setup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed nits Created 9 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/extensions/app_notify_channel_setup.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/app_notification_browsertest.cc
diff --git a/chrome/browser/extensions/app_notification_browsertest.cc b/chrome/browser/extensions/app_notification_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..899d743604cef43a4b05007b8207c40061bd5b7b
--- /dev/null
+++ b/chrome/browser/extensions/app_notification_browsertest.cc
@@ -0,0 +1,80 @@
+// 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.
+
+#include "base/command_line.h"
+#include "chrome/browser/extensions/app_notify_channel_setup.h"
+#include "chrome/browser/extensions/extension_browsertest.h"
+#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/common/extensions/extension.h"
+#include "chrome/test/base/ui_test_utils.h"
+#include "content/public/browser/browser_thread.h"
+
+using content::BrowserThread;
+
+class AppNotificationTest : public ExtensionBrowserTest {
+ public:
+ void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
+ ExtensionBrowserTest::SetUpCommandLine(command_line);
+ command_line->AppendSwitch(
+ switches::kEnableExperimentalExtensionApis);
+ }
+};
+
+namespace {
+
+// Our test app will call the getNotificationChannel API using this client id.
+static const char* kExpectedClientId = "dummy_client_id";
+
+class Interceptor : public AppNotifyChannelSetup::InterceptorForTests {
+ public:
+ Interceptor() : was_called_(false) {}
+ virtual ~Interceptor() {}
+
+ virtual void DoIntercept(const AppNotifyChannelSetup* setup,
+ std::string* result_channel_id,
+ std::string* result_error) OVERRIDE {
+ EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ EXPECT_TRUE(setup->client_id() == std::string(kExpectedClientId));
+ *result_channel_id = std::string("1234");
+ *result_error = std::string();
+ was_called_ = true;
+ MessageLoop::current()->Quit();
+ }
+
+ bool was_called() const { return was_called_; }
+
+ private:
+ bool was_called_;
+};
+
+
+} // namespace
+
+// A test that makes sure we properly save the client id we were passed when
+// the app called the getNotificationChannel API.
+IN_PROC_BROWSER_TEST_F(AppNotificationTest, SaveClientId) {
+ Interceptor interceptor;
+ AppNotifyChannelSetup::SetInterceptorForTests(&interceptor);
+
+ const Extension* app =
+ LoadExtension(test_data_dir_.AppendASCII("app_notifications"));
+ ASSERT_TRUE(app != NULL);
+
+ Browser::OpenApplication(browser()->profile(),
+ app,
+ extension_misc::LAUNCH_TAB,
+ GURL(),
+ NEW_FOREGROUND_TAB);
+ if (!interceptor.was_called())
+ ui_test_utils::RunMessageLoop();
+ EXPECT_TRUE(interceptor.was_called());
+
+ ExtensionService* service = browser()->profile()->GetExtensionService();
+ ExtensionPrefs* prefs = service->extension_prefs();
+ std::string saved_id = prefs->GetAppNotificationClientId(app->id());
+ EXPECT_TRUE(std::string(kExpectedClientId) == saved_id);
+}
« no previous file with comments | « no previous file | chrome/browser/extensions/app_notify_channel_setup.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698