Chromium Code Reviews| 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/api/dial/dial_api.h" | 6 #include "chrome/browser/extensions/api/dial/dial_api.h" |
| 7 #include "chrome/browser/extensions/api/dial/dial_api_factory.h" | 7 #include "chrome/browser/extensions/api/dial/dial_api_factory.h" |
| 8 #include "chrome/browser/extensions/api/dial/dial_registry.h" | 8 #include "chrome/browser/extensions/api/dial/dial_registry.h" |
| 9 #include "chrome/browser/extensions/extension_apitest.h" | 9 #include "chrome/browser/extensions/extension_apitest.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 // Setup the test. | 45 // Setup the test. |
| 46 ASSERT_TRUE(RunExtensionSubtest("dial/experimental", "device_list.html")); | 46 ASSERT_TRUE(RunExtensionSubtest("dial/experimental", "device_list.html")); |
| 47 | 47 |
| 48 // Send three device list updates. | 48 // Send three device list updates. |
| 49 scoped_refptr<extensions::DialAPI> api = | 49 scoped_refptr<extensions::DialAPI> api = |
| 50 extensions::DialAPIFactory::GetInstance()->GetForBrowserContext( | 50 extensions::DialAPIFactory::GetInstance()->GetForBrowserContext( |
| 51 profile()); | 51 profile()); |
| 52 ASSERT_TRUE(api.get()); | 52 ASSERT_TRUE(api.get()); |
| 53 extensions::DialRegistry::DeviceList devices; | 53 extensions::DialRegistry::DeviceList devices; |
| 54 | 54 |
| 55 | |
| 56 ResultCatcher catcher; | 55 ResultCatcher catcher; |
| 57 | 56 |
| 58 DialDeviceData device1; | 57 DialDeviceData device1; |
| 59 device1.set_device_id("1"); | 58 device1.set_device_id("1"); |
| 60 device1.set_label("1"); | 59 device1.set_label("1"); |
| 61 device1.set_device_description_url(GURL("http://127.0.0.1/dd.xml")); | 60 device1.set_device_description_url(GURL("http://127.0.0.1/dd.xml")); |
| 62 | 61 |
| 63 devices.push_back(device1); | 62 devices.push_back(device1); |
| 64 api->SendEventOnUIThread(devices); | 63 api->SendEventOnUIThread(devices); |
| 65 | 64 |
| 66 DialDeviceData device2; | 65 DialDeviceData device2; |
| 67 device2.set_device_id("2"); | 66 device2.set_device_id("2"); |
| 68 device2.set_label("2"); | 67 device2.set_label("2"); |
| 69 device2.set_device_description_url(GURL("http://127.0.0.2/dd.xml")); | 68 device2.set_device_description_url(GURL("http://127.0.0.2/dd.xml")); |
| 70 | 69 |
| 71 devices.push_back(device2); | 70 devices.push_back(device2); |
| 72 api->SendEventOnUIThread(devices); | 71 api->SendEventOnUIThread(devices); |
| 73 | 72 |
| 74 DialDeviceData device3; | 73 DialDeviceData device3; |
| 75 device3.set_device_id("3"); | 74 device3.set_device_id("3"); |
| 76 device3.set_label("3"); | 75 device3.set_label("3"); |
| 77 device3.set_device_description_url(GURL("http://127.0.0.3/dd.xml")); | 76 device3.set_device_description_url(GURL("http://127.0.0.3/dd.xml")); |
| 78 | 77 |
| 79 devices.push_back(device3); | 78 devices.push_back(device3); |
| 80 api->SendEventOnUIThread(devices); | 79 api->SendEventOnUIThread(devices); |
| 81 | 80 |
| 82 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 81 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 83 } | 82 } |
| 84 | 83 |
| 85 // Test discoverNow fails if there are no listeners. When there are no listeners | |
| 86 // the DIAL API will not be active. | |
| 87 IN_PROC_BROWSER_TEST_F(DialAPITest, Discovery) { | 84 IN_PROC_BROWSER_TEST_F(DialAPITest, Discovery) { |
|
Wez
2014/08/28 19:59:52
So the Discovery test is now doing discovery _with
mark a. foltz
2014/08/28 20:14:50
Acknowledged.
| |
| 88 ASSERT_TRUE(RunExtensionSubtest("dial/experimental", "discovery.html")); | 85 ASSERT_TRUE(RunExtensionSubtest("dial/experimental", "discovery.html")); |
| 89 } | 86 } |
| 90 | 87 |
| 88 // discoverNow does not do discovery when there are no listeners; in that case | |
| 89 // the DIAL service will not be active. | |
| 90 IN_PROC_BROWSER_TEST_F(DialAPITest, DiscoveryNoListeners) { | |
| 91 ASSERT_TRUE(RunExtensionSubtest("dial/experimental", | |
| 92 "discovery_no_listeners.html")); | |
| 93 } | |
| 94 | |
| 91 // Make sure this API is only accessible to whitelisted extensions. | 95 // Make sure this API is only accessible to whitelisted extensions. |
| 92 IN_PROC_BROWSER_TEST_F(DialAPITest, NonWhitelistedExtension) { | 96 IN_PROC_BROWSER_TEST_F(DialAPITest, NonWhitelistedExtension) { |
| 93 ResultCatcher catcher; | 97 ResultCatcher catcher; |
| 94 catcher.RestrictToProfile(browser()->profile()); | 98 catcher.RestrictToProfile(browser()->profile()); |
| 95 | 99 |
| 96 ExtensionTestMessageListener listener("ready", true); | 100 ExtensionTestMessageListener listener("ready", true); |
| 97 const extensions::Extension* extension = LoadExtensionWithFlags( | 101 const extensions::Extension* extension = LoadExtensionWithFlags( |
| 98 test_data_dir_.AppendASCII("dial/whitelist"), | 102 test_data_dir_.AppendASCII("dial/whitelist"), |
| 99 ExtensionBrowserTest::kFlagIgnoreManifestWarnings); | 103 ExtensionBrowserTest::kFlagIgnoreManifestWarnings); |
| 100 // We should have a DIAL API not available warning. | 104 // We should have a DIAL API not available warning. |
| 101 ASSERT_FALSE(extension->install_warnings().empty()); | 105 ASSERT_FALSE(extension->install_warnings().empty()); |
| 102 | 106 |
| 103 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 107 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
| 104 | 108 |
| 105 listener.Reply("go"); | 109 listener.Reply("go"); |
| 106 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 110 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 107 } | 111 } |
| 108 | 112 |
| 109 IN_PROC_BROWSER_TEST_F(DialAPITest, OnError) { | 113 IN_PROC_BROWSER_TEST_F(DialAPITest, OnError) { |
| 110 ASSERT_TRUE(RunExtensionSubtest("dial/experimental", "on_error.html")); | 114 ASSERT_TRUE(RunExtensionSubtest("dial/experimental", "on_error.html")); |
| 111 } | 115 } |
| OLD | NEW |