OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 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/extension_apitest.h" | |
7 #include "chromeos/dbus/dbus_thread_manager.h" | |
8 #include "chromeos/dbus/fake_media_analytics_client.h" | |
9 #include "chromeos/dbus/media_analytics_client.h" | |
10 #include "extensions/browser/api/media_perception_private/media_perception_priva te_api.h" | |
11 #include "extensions/common/switches.h" | |
12 #include "extensions/test/extension_test_message_listener.h" | |
13 | |
14 namespace extensions { | |
15 | |
16 class MediaPerceptionPrivateApiTest : public ExtensionApiTest { | |
17 public: | |
18 MediaPerceptionPrivateApiTest() {} | |
19 | |
20 void SetUpCommandLine(base::CommandLine* command_line) override { | |
21 ExtensionApiTest::SetUpCommandLine(command_line); | |
22 // Whitelist of the extension ID of the test extension. | |
23 command_line->AppendSwitchASCII( | |
24 extensions::switches::kWhitelistedExtensionID, | |
25 "epcifkihnkjgphfkloaaleeakhpmgdmn"); | |
26 } | |
27 | |
28 void InitializeDbusClient() { | |
tbarzic
2017/05/11 00:38:27
This is not really initializing D bus client, mayb
Luke Sorenson
2017/05/11 23:58:00
Done.
| |
29 dbus_client_ = reinterpret_cast<chromeos::FakeMediaAnalyticsClient*>( | |
tbarzic
2017/05/11 00:38:27
Can you check if you can use DBusThreadManager::G
Luke Sorenson
2017/05/11 23:57:59
Done.
| |
30 chromeos::DBusThreadManager::Get()->GetMediaAnalyticsClient()); | |
31 } | |
32 | |
33 ~MediaPerceptionPrivateApiTest() override {} | |
tbarzic
2017/05/11 00:38:27
move this after ctor;
use = default where possible
Luke Sorenson
2017/05/11 23:57:59
Done.
| |
34 | |
35 chromeos::FakeMediaAnalyticsClient* dbus_client_; | |
tbarzic
2017/05/11 00:38:27
DISALLOW_COPY_AND_ASSIGN
Luke Sorenson
2017/05/11 23:57:59
Done.
| |
36 }; | |
37 | |
38 // Verify that we can set and get mediaPerception system state. | |
39 IN_PROC_BROWSER_TEST_F(MediaPerceptionPrivateApiTest, State) { | |
40 ASSERT_TRUE(RunPlatformAppTest("media_perception_private/state")) << message_; | |
41 } | |
42 | |
43 // Verify that we can request Diagnostics. | |
44 IN_PROC_BROWSER_TEST_F(MediaPerceptionPrivateApiTest, GetDiagnostics) { | |
45 InitializeDbusClient(); | |
46 // Allows us to validate that the right data comes through the code path. | |
47 dbus_client_->SetFrameId(1); | |
48 | |
49 ASSERT_TRUE(RunPlatformAppTest("media_perception_private/diagnostics")) | |
50 << message_; | |
51 } | |
52 | |
53 // Verify that we can listen for MediaPerceptionDetection signals and handle | |
54 // them. | |
55 IN_PROC_BROWSER_TEST_F(MediaPerceptionPrivateApiTest, MediaPerception) { | |
56 ExtensionTestMessageListener handler_registered_listener( | |
57 "mediaPerceptionListenerSet", false); | |
58 ASSERT_TRUE(LoadExtension( | |
59 test_data_dir_.AppendASCII("media_perception_private/media_perception"))) | |
60 << message_; | |
61 ASSERT_TRUE(handler_registered_listener.WaitUntilSatisfied()); | |
62 | |
63 InitializeDbusClient(); | |
64 // Allows us to validate that the right data comes through the code path. | |
65 dbus_client_->SetFrameId(1); | |
tbarzic
2017/05/11 00:38:27
do you need this for this test?
Luke Sorenson
2017/05/11 23:57:59
Done.
| |
66 dbus_client_->FireMediaPerceptionEvent(); | |
67 } | |
68 | |
69 } // namespace extensions | |
OLD | NEW |