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

Side by Side Diff: chrome/browser/extensions/api/media_galleries_private/media_galleries_watch_apitest.cc

Issue 332003002: Enable gallery watches on Mac (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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
« no previous file with comments | « chrome/browser/extensions/api/media_galleries_private/media_galleries_private_api.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // MediaGalleriesPrivate gallery watch API browser tests. 5 // MediaGalleriesPrivate gallery watch API browser tests.
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "chrome/browser/extensions/extension_apitest.h" 12 #include "chrome/browser/extensions/extension_apitest.h"
13 #include "chrome/browser/extensions/extension_service.h" 13 #include "chrome/browser/extensions/extension_service.h"
14 #include "chrome/browser/extensions/extension_test_message_listener.h" 14 #include "chrome/browser/extensions/extension_test_message_listener.h"
15 #include "chrome/browser/media_galleries/media_galleries_test_util.h" 15 #include "chrome/browser/media_galleries/media_galleries_test_util.h"
16 #include "chrome/common/chrome_paths.h" 16 #include "chrome/common/chrome_paths.h"
17 #include "content/public/browser/render_frame_host.h" 17 #include "content/public/browser/render_frame_host.h"
18 #include "content/public/browser/render_view_host.h" 18 #include "content/public/browser/render_view_host.h"
19 #include "extensions/browser/extension_system.h" 19 #include "extensions/browser/extension_system.h"
20 #include "extensions/common/extension.h" 20 #include "extensions/common/extension.h"
21 #include "extensions/common/switches.h" 21 #include "extensions/common/switches.h"
22 22
23 namespace { 23 namespace {
24 24
25 // Id of test extension from 25 // Id of test extension from
26 // chrome/test/data/extensions/api_test/|kTestExtensionPath| 26 // chrome/test/data/extensions/api_test/|kTestExtensionPath|
27 const char kTestExtensionId[] = "gceegfkgibmgpfopknlcgleimclbknie"; 27 const char kTestExtensionId[] = "gceegfkgibmgpfopknlcgleimclbknie";
28 const char kTestExtensionPath[] = "media_galleries_private/gallerywatch"; 28 const char kTestExtensionPath[] = "media_galleries_private/gallerywatch";
29 29
30 #if !defined(OS_CHROMEOS)
vandebo (ex-Chrome) 2014/06/14 00:45:11 We'll see what happens when this comes out...
31 // JS commands. 30 // JS commands.
32 const char kGetAllWatchedGalleryIdsCmd[] = "getAllWatchedGalleryIds()"; 31 const char kGetAllWatchedGalleryIdsCmd[] = "getAllWatchedGalleryIds()";
33 const char kGetMediaFileSystemsCmd[] = "getMediaFileSystems()"; 32 const char kGetMediaFileSystemsCmd[] = "getMediaFileSystems()";
34 const char kSetupWatchOnValidGalleriesCmd[] = "setupWatchOnValidGalleries()"; 33 const char kSetupWatchOnValidGalleriesCmd[] = "setupWatchOnValidGalleries()";
35 #if defined(OS_WIN) || defined(OS_LINUX)
36 const char kAddGalleryChangedListenerCmd[] = "addGalleryChangedListener()"; 34 const char kAddGalleryChangedListenerCmd[] = "addGalleryChangedListener()";
37 const char kRemoveAllGalleryWatchCmd[] = "removeAllGalleryWatch()"; 35 const char kRemoveAllGalleryWatchCmd[] = "removeAllGalleryWatch()";
38 const char kRemoveGalleryChangedListenerCmd[] = 36 const char kRemoveGalleryChangedListenerCmd[] =
39 "removeGalleryChangedListener()"; 37 "removeGalleryChangedListener()";
40 const char kRemoveGalleryWatchCmd[] = "removeGalleryWatch()"; 38 const char kRemoveGalleryWatchCmd[] = "removeGalleryWatch()";
41 const char kSetupWatchOnInvalidGalleryCmd[] = "setupWatchOnInvalidGallery()"; 39 const char kSetupWatchOnInvalidGalleryCmd[] = "setupWatchOnInvalidGallery()";
42 #endif // defined(OS_WIN) || defined(OS_LINUX)
43 40
44 // And JS reply messages. 41 // And JS reply messages.
45 const char kAddGalleryWatchOK[] = "add_gallery_watch_ok"; 42 const char kAddGalleryWatchOK[] = "add_gallery_watch_ok";
46 const char kGetAllGalleryWatchOK[] = "get_all_gallery_watch_ok"; 43 const char kGetAllGalleryWatchOK[] = "get_all_gallery_watch_ok";
47 const char kGetMediaFileSystemsCallbackOK[] = 44 const char kGetMediaFileSystemsCallbackOK[] =
48 "get_media_file_systems_callback_ok"; 45 "get_media_file_systems_callback_ok";
49 const char kGetMediaFileSystemsOK[] = "get_media_file_systems_ok"; 46 const char kGetMediaFileSystemsOK[] = "get_media_file_systems_ok";
50 #if defined(OS_WIN) || defined(OS_LINUX)
51 const char kAddGalleryChangedListenerOK[] = "add_gallery_changed_listener_ok"; 47 const char kAddGalleryChangedListenerOK[] = "add_gallery_changed_listener_ok";
52 const char kRemoveAllGalleryWatchOK[] = "remove_all_gallery_watch_ok"; 48 const char kRemoveAllGalleryWatchOK[] = "remove_all_gallery_watch_ok";
53 const char kRemoveGalleryChangedListenerOK[] = 49 const char kRemoveGalleryChangedListenerOK[] =
54 "remove_gallery_changed_listener_ok"; 50 "remove_gallery_changed_listener_ok";
55 const char kRemoveGalleryWatchOK[] = "remove_gallery_watch_ok"; 51 const char kRemoveGalleryWatchOK[] = "remove_gallery_watch_ok";
56 #endif // defined(OS_WIN) || defined(OS_LINUX)
57 52
58 // Test reply messages. 53 // Test reply messages.
59 const char kGetAllGalleryWatchResultA[] = "gallery_watchers_does_not_exists"; 54 const char kGetAllGalleryWatchResultA[] = "gallery_watchers_does_not_exists";
60 const char kAddGalleryWatchRequestFailed[] = "add_watch_request_failed"; 55 const char kAddGalleryWatchRequestFailed[] = "add_watch_request_failed";
61 #if defined(OS_WIN) || defined(OS_LINUX)
62 const char kAddGalleryWatchRequestSucceeded[] = "add_watch_request_succeeded"; 56 const char kAddGalleryWatchRequestSucceeded[] = "add_watch_request_succeeded";
63 const char kGalleryChangedEventReceived[] = "gallery_changed_event_received"; 57 const char kGalleryChangedEventReceived[] = "gallery_changed_event_received";
64 const char kGetAllGalleryWatchResultB[] = 58 const char kGetAllGalleryWatchResultB[] =
65 "watchers_for_galleries_{1, 2, 3}_found"; 59 "watchers_for_galleries_{1, 2, 3}_found";
66 #endif // defined(OS_WIN) || defined(OS_LINUX)
67 #endif // !defined(OS_CHROMEOS)
68 60
69 } // namespace 61 } // namespace
70 62
71 63
72 /////////////////////////////////////////////////////////////////////////////// 64 ///////////////////////////////////////////////////////////////////////////////
73 // MediaGalleriesPrivateGalleryWatchApiTest // 65 // MediaGalleriesPrivateGalleryWatchApiTest //
74 /////////////////////////////////////////////////////////////////////////////// 66 ///////////////////////////////////////////////////////////////////////////////
75 67
76 class MediaGalleriesPrivateGalleryWatchApiTest : public ExtensionApiTest { 68 class MediaGalleriesPrivateGalleryWatchApiTest : public ExtensionApiTest {
77 public: 69 public:
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 return NULL; 113 return NULL;
122 return extensions::ExtensionSystem::Get(browser()->profile())-> 114 return extensions::ExtensionSystem::Get(browser()->profile())->
123 process_manager()->GetBackgroundHostForExtension(extension->id())-> 115 process_manager()->GetBackgroundHostForExtension(extension->id())->
124 render_view_host(); 116 render_view_host();
125 } 117 }
126 118
127 private: 119 private:
128 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesPrivateGalleryWatchApiTest); 120 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesPrivateGalleryWatchApiTest);
129 }; 121 };
130 122
131
132 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS))
133 IN_PROC_BROWSER_TEST_F(MediaGalleriesPrivateGalleryWatchApiTest, 123 IN_PROC_BROWSER_TEST_F(MediaGalleriesPrivateGalleryWatchApiTest,
134 BasicGalleryWatch) { 124 BasicGalleryWatch) {
135 EnsureMediaDirectoriesExists media_directories; 125 EnsureMediaDirectoriesExists media_directories;
136 content::RenderViewHost* host = GetBackgroundHostForTestExtension(); 126 content::RenderViewHost* host = GetBackgroundHostForTestExtension();
137 ASSERT_TRUE(host); 127 ASSERT_TRUE(host);
138 128
139 // Get media file systems. 129 // Get media file systems.
140 ExtensionTestMessageListener get_media_systems_finished( 130 ExtensionTestMessageListener get_media_systems_finished(
141 kGetMediaFileSystemsCallbackOK, false /* no reply */); 131 kGetMediaFileSystemsCallbackOK, false /* no reply */);
142 ExecuteCmdAndCheckReply(host, kGetMediaFileSystemsCmd, 132 ExecuteCmdAndCheckReply(host, kGetMediaFileSystemsCmd,
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 kRemoveAllGalleryWatchOK); 358 kRemoveAllGalleryWatchOK);
369 359
370 // Gallery watchers removed. chrome.mediaGalleriesPrivate.getAllGalleryWatch 360 // Gallery watchers removed. chrome.mediaGalleriesPrivate.getAllGalleryWatch
371 // should return an empty list. 361 // should return an empty list.
372 ExtensionTestMessageListener final_get_all_check_finished( 362 ExtensionTestMessageListener final_get_all_check_finished(
373 kGetAllGalleryWatchResultA, false /* no reply */); 363 kGetAllGalleryWatchResultA, false /* no reply */);
374 ExecuteCmdAndCheckReply(host, kGetAllWatchedGalleryIdsCmd, 364 ExecuteCmdAndCheckReply(host, kGetAllWatchedGalleryIdsCmd,
375 kGetAllGalleryWatchOK); 365 kGetAllGalleryWatchOK);
376 EXPECT_TRUE(final_get_all_check_finished.WaitUntilSatisfied()); 366 EXPECT_TRUE(final_get_all_check_finished.WaitUntilSatisfied());
377 } 367 }
378 #endif // defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS))
379
380 #if defined(OS_MACOSX)
381 // Gallery watch request is not enabled on Mac: crbug.com/144491.
382 IN_PROC_BROWSER_TEST_F(MediaGalleriesPrivateGalleryWatchApiTest,
383 SetupGalleryWatch) {
384 EnsureMediaDirectoriesExists media_directories;
385 content::RenderViewHost* host = GetBackgroundHostForTestExtension();
386 ASSERT_TRUE(host);
387
388 // Get media file systems.
389 ExtensionTestMessageListener get_media_systems_finished(
390 kGetMediaFileSystemsCallbackOK, false /* no reply */);
391 ExecuteCmdAndCheckReply(host, kGetMediaFileSystemsCmd,
392 kGetMediaFileSystemsOK);
393 EXPECT_TRUE(get_media_systems_finished.WaitUntilSatisfied());
394
395 // Set up a invalid gallery watch.
396 ExtensionTestMessageListener gallery_watch_request_finished(
397 kAddGalleryWatchRequestFailed, false /* no reply */);
398 // Set up gallery watch.
399 ExecuteCmdAndCheckReply(host, kSetupWatchOnValidGalleriesCmd,
400 kAddGalleryWatchOK);
401 EXPECT_TRUE(gallery_watch_request_finished.WaitUntilSatisfied());
402 }
403
404 IN_PROC_BROWSER_TEST_F(MediaGalleriesPrivateGalleryWatchApiTest,
405 GetAllGalleryWatch) {
406 EnsureMediaDirectoriesExists media_directories;
407 content::RenderViewHost* host = GetBackgroundHostForTestExtension();
408 ASSERT_TRUE(host);
409
410 // Get media file systems.
411 ExtensionTestMessageListener get_media_systems_finished(
412 kGetMediaFileSystemsCallbackOK, false /* no reply */);
413 ExecuteCmdAndCheckReply(host, kGetMediaFileSystemsCmd,
414 kGetMediaFileSystemsOK);
415 EXPECT_TRUE(get_media_systems_finished.WaitUntilSatisfied());
416
417 // Set up gallery watch.
418 ExecuteCmdAndCheckReply(host, kSetupWatchOnValidGalleriesCmd,
419 kAddGalleryWatchOK);
420
421 // Gallery watchers does not exists.
422 // chrome.mediaGalleriesPrivate.getAllGalleryWatch should return an empty
423 // list.
424 ExtensionTestMessageListener get_all_gallery_watch_finished(
425 kGetAllGalleryWatchResultA, false /* no reply */);
426 ExecuteCmdAndCheckReply(host, kGetAllWatchedGalleryIdsCmd,
427 kGetAllGalleryWatchOK);
428 EXPECT_TRUE(get_all_gallery_watch_finished.WaitUntilSatisfied());
429 }
430 #endif // defined(OS_MACOSX)
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/media_galleries_private/media_galleries_private_api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698