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

Side by Side 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 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 "chrome/browser/chromeos/contacts/contact.pb.h"
6 #include "chrome/browser/extensions/api/rtc_private/rtc_private_api.h"
7 #include "chrome/browser/extensions/extension_apitest.h"
8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/common/chrome_switches.h"
11 #include "chrome/common/extensions/extension.h"
12 #include "chrome/test/base/ui_test_utils.h"
13 #include "content/public/browser/web_contents.h"
14 #include "content/public/test/browser_test_utils.h"
15 #include "googleurl/src/gurl.h"
16
17 namespace {
18
19 // Id of test extension from
20 // chrome/test/data/extensions/api_test/rtc_private/events.
21 const char kTestRtcExtensionId[] = "jdaiaafaoeaejklkkbndacnggmgmpkpa";
22 // Test contact data.
23 const char kContactFullName[] = "Test Contact";
24 const char kTestEmail_1[] = "test_1@something.com";
25 const char kTestEmail_2[] = "test_2@something.com";
26 const char kTestPhone_1[] = "(555) 111-2222";
27 const char kTestPhone_2[] = "(555) 333-4444";
28
29 } // namespace
30
31 class RtcPrivateApiTest : public ExtensionApiTest {
32 protected:
33 // ExtensionApiTest overrides.
34 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
35 ExtensionApiTest::SetUpCommandLine(command_line);
36 command_line->AppendSwitchASCII(switches::kWhitelistedExtensionID,
37 kTestRtcExtensionId);
38 command_line->AppendSwitch(switches::kEnableContacts);
39 }
40
41 static contacts::Contact* CreateTestContact() {
42 contacts::Contact* contact = new contacts::Contact();
43 contact->set_full_name(kContactFullName);
44 contacts::Contact_EmailAddress* address_1 =
45 contact->mutable_email_addresses()->Add();
46 address_1->set_address(kTestEmail_1);
47 contacts::Contact_EmailAddress* address_2 =
48 contact->mutable_email_addresses()->Add();
49 address_2->set_address(kTestEmail_2);
50
51 contacts::Contact_PhoneNumber* number_1 =
52 contact->mutable_phone_numbers()->Add();
53 number_1->set_number(kTestPhone_1);
54 contacts::Contact_PhoneNumber* number_2 =
55 contact->mutable_phone_numbers()->Add();
56 number_2->set_number(kTestPhone_2);
57 return contact;
58 }
59 };
60
61 IN_PROC_BROWSER_TEST_F(RtcPrivateApiTest, LaunchEvents) {
62 // Load test RTC extension.
63 const extensions::Extension* extension = LoadExtension(
64 test_data_dir_.AppendASCII("rtc_private/events"));
65 ASSERT_TRUE(extension);
66
67 // Raise all RTC-related events.
68 scoped_ptr<contacts::Contact> contact(CreateTestContact());
69 extensions::RtcPrivateApi::RaiseLaunchEvent(
70 browser()->profile(),
71 extensions::RtcPrivateApi::LAUNCH_ACTIVATE,
72 contact.get());
73
74 extensions::RtcPrivateApi::RaiseLaunchEvent(
75 browser()->profile(),
76 extensions::RtcPrivateApi::LAUNCH_CHAT,
77 contact.get());
78
79 extensions::RtcPrivateApi::RaiseLaunchEvent(
80 browser()->profile(),
81 extensions::RtcPrivateApi::LAUNCH_VIDEO,
82 contact.get());
83
84 extensions::RtcPrivateApi::RaiseLaunchEvent(
85 browser()->profile(),
86 extensions::RtcPrivateApi::LAUNCH_VOICE,
87 contact.get());
88
89 // Collect results to make sure all web intents have been received on
90 // the test extension side.
91 ResultCatcher catcher;
92 ui_test_utils::NavigateToURL(
93 browser(), extension->GetResourceURL("check_events.html"));
94 EXPECT_TRUE(catcher.GetNextResult());
95 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698