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

Unified Diff: chrome/browser/extensions/api/rtc_private/rtc_private_apitest.cc

Issue 10919086: Wired chrome.rtcPrivate API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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/extensions/api/rtc_private/rtc_private_apitest.cc
diff --git a/chrome/browser/extensions/api/rtc_private/rtc_private_apitest.cc b/chrome/browser/extensions/api/rtc_private/rtc_private_apitest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..30f776dc9a9902bf03d47643ab8fafc7c2e1307d
--- /dev/null
+++ b/chrome/browser/extensions/api/rtc_private/rtc_private_apitest.cc
@@ -0,0 +1,96 @@
+// Copyright (c) 2012 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 "chrome/browser/chromeos/contacts/contact.pb.h"
+#include "chrome/browser/extensions/api/rtc_private/rtc_private_api.h"
+#include "chrome/browser/extensions/extension_apitest.h"
+#include "chrome/browser/extensions/extension_service.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/web_contents.h"
+#include "content/public/test/browser_test_utils.h"
+#include "googleurl/src/gurl.h"
+
+namespace {
+
+// Id of test extension from
+// chrome/test/data/extensions/api_test/rtc_private/events.
+const char kTestRtcExtensionId[] = "jdaiaafaoeaejklkkbndacnggmgmpkpa";
+// Test contact data.
+const char kContactFullName[] = "Test Contact";
+const char kTestEmail_1[] = "test_1@something.com";
+const char kTestEmail_2[] = "test_2@something.com";
+const char kTestPhone_1[] = "(555) 111-2222";
+const char kTestPhone_2[] = "(555) 333-4444";
+
+} // namespace
+
+class RtcPrivateApiTest : public ExtensionApiTest {
+ protected:
+ // ExtensionApiTest overrides.
+ virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
+ ExtensionApiTest::SetUpCommandLine(command_line);
+ command_line->AppendSwitchASCII(switches::kWhitelistedExtensionID,
+ kTestRtcExtensionId);
+ command_line->AppendSwitch(switches::kEnableContacts);
+ }
+
+ static contacts::Contact* CreateTestContact() {
+ contacts::Contact* contact = new contacts::Contact();
+ contact->set_full_name(kContactFullName);
+ contacts::Contact_EmailAddress* address_1 =
+ contact->mutable_email_addresses()->Add();
+ address_1->set_address(kTestEmail_1);
+ contacts::Contact_EmailAddress* address_2 =
+ contact->mutable_email_addresses()->Add();
+ address_2->set_address(kTestEmail_2);
+
+ contacts::Contact_PhoneNumber* number_1 =
+ contact->mutable_phone_numbers()->Add();
+ number_1->set_number(kTestPhone_1);
+ contacts::Contact_PhoneNumber* number_2 =
+ contact->mutable_phone_numbers()->Add();
+ number_2->set_number(kTestPhone_2);
+ return contact;
+ }
+};
+
+
+IN_PROC_BROWSER_TEST_F(RtcPrivateApiTest, LaunchEvents) {
+ // Load test RTC extension.
+ const extensions::Extension* extension = LoadExtension(
+ test_data_dir_.AppendASCII("rtc_private/events"));
+ ASSERT_TRUE(extension);
+
+ // Raise all RTC-related events.
+ scoped_ptr<contacts::Contact> contact(CreateTestContact());
+ extensions::RtcPrivateApi::RaiseLaunchEvent(
+ browser()->profile(),
+ extensions::RtcPrivateApi::LAUNCH_ACTIVATE,
+ contact.get());
+
+ extensions::RtcPrivateApi::RaiseLaunchEvent(
+ browser()->profile(),
+ extensions::RtcPrivateApi::LAUNCH_CHAT,
+ contact.get());
+
+ extensions::RtcPrivateApi::RaiseLaunchEvent(
+ browser()->profile(),
+ extensions::RtcPrivateApi::LAUNCH_VIDEO,
+ contact.get());
+
+ extensions::RtcPrivateApi::RaiseLaunchEvent(
+ browser()->profile(),
+ extensions::RtcPrivateApi::LAUNCH_VOICE,
+ contact.get());
+
+ // Collect results to make sure all web intents have been received on
+ // the test extension side.
+ ResultCatcher catcher;
+ ui_test_utils::NavigateToURL(
+ browser(), extension->GetResourceURL("check_events.html"));
+ EXPECT_TRUE(catcher.GetNextResult());
+}

Powered by Google App Engine
This is Rietveld 408576698