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

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

Issue 282153002: Media Galleries: Enable chrome.mediaGalleriesPrivate.onGalleryChanged and friends on Linux. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 7 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"
(...skipping 14 matching lines...) Expand all
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) 30 #if !defined(OS_CHROMEOS)
31 // JS commands. 31 // JS commands.
32 const char kGetAllWatchedGalleryIdsCmd[] = "getAllWatchedGalleryIds()"; 32 const char kGetAllWatchedGalleryIdsCmd[] = "getAllWatchedGalleryIds()";
33 const char kGetMediaFileSystemsCmd[] = "getMediaFileSystems()"; 33 const char kGetMediaFileSystemsCmd[] = "getMediaFileSystems()";
34 const char kSetupWatchOnValidGalleriesCmd[] = "setupWatchOnValidGalleries()"; 34 const char kSetupWatchOnValidGalleriesCmd[] = "setupWatchOnValidGalleries()";
35 #if defined(OS_WIN) 35 #if defined(OS_WIN) || defined(OS_LINUX)
36 const char kAddGalleryChangedListenerCmd[] = "addGalleryChangedListener()"; 36 const char kAddGalleryChangedListenerCmd[] = "addGalleryChangedListener()";
37 const char kRemoveAllGalleryWatchCmd[] = "removeAllGalleryWatch()"; 37 const char kRemoveAllGalleryWatchCmd[] = "removeAllGalleryWatch()";
38 const char kRemoveGalleryChangedListenerCmd[] = 38 const char kRemoveGalleryChangedListenerCmd[] =
39 "removeGalleryChangedListener()"; 39 "removeGalleryChangedListener()";
40 const char kRemoveGalleryWatchCmd[] = "removeGalleryWatch()"; 40 const char kRemoveGalleryWatchCmd[] = "removeGalleryWatch()";
41 const char kSetupWatchOnInvalidGalleryCmd[] = "setupWatchOnInvalidGallery()"; 41 const char kSetupWatchOnInvalidGalleryCmd[] = "setupWatchOnInvalidGallery()";
42 #endif // defined(OS_WIN) 42 #endif // defined(OS_WIN) || defined(OS_LINUX)
43 43
44 // And JS reply messages. 44 // And JS reply messages.
45 const char kAddGalleryWatchOK[] = "add_gallery_watch_ok"; 45 const char kAddGalleryWatchOK[] = "add_gallery_watch_ok";
46 const char kGetAllGalleryWatchOK[] = "get_all_gallery_watch_ok"; 46 const char kGetAllGalleryWatchOK[] = "get_all_gallery_watch_ok";
47 const char kGetMediaFileSystemsCallbackOK[] = 47 const char kGetMediaFileSystemsCallbackOK[] =
48 "get_media_file_systems_callback_ok"; 48 "get_media_file_systems_callback_ok";
49 const char kGetMediaFileSystemsOK[] = "get_media_file_systems_ok"; 49 const char kGetMediaFileSystemsOK[] = "get_media_file_systems_ok";
50 #if defined(OS_WIN) 50 #if defined(OS_WIN) || defined(OS_LINUX)
51 const char kAddGalleryChangedListenerOK[] = "add_gallery_changed_listener_ok"; 51 const char kAddGalleryChangedListenerOK[] = "add_gallery_changed_listener_ok";
52 const char kRemoveAllGalleryWatchOK[] = "remove_all_gallery_watch_ok"; 52 const char kRemoveAllGalleryWatchOK[] = "remove_all_gallery_watch_ok";
53 const char kRemoveGalleryChangedListenerOK[] = 53 const char kRemoveGalleryChangedListenerOK[] =
54 "remove_gallery_changed_listener_ok"; 54 "remove_gallery_changed_listener_ok";
55 const char kRemoveGalleryWatchOK[] = "remove_gallery_watch_ok"; 55 const char kRemoveGalleryWatchOK[] = "remove_gallery_watch_ok";
56 #endif // defined(OS_WIN) 56 #endif // defined(OS_WIN) || defined(OS_LINUX)
57 57
58 // Test reply messages. 58 // Test reply messages.
59 const char kGetAllGalleryWatchResultA[] = "gallery_watchers_does_not_exists"; 59 const char kGetAllGalleryWatchResultA[] = "gallery_watchers_does_not_exists";
60 const char kAddGalleryWatchRequestFailed[] = "add_watch_request_failed"; 60 const char kAddGalleryWatchRequestFailed[] = "add_watch_request_failed";
61 #if defined(OS_WIN) 61 #if defined(OS_WIN) || defined(OS_LINUX)
62 const char kAddGalleryWatchRequestSucceeded[] = "add_watch_request_succeeded"; 62 const char kAddGalleryWatchRequestSucceeded[] = "add_watch_request_succeeded";
63 const char kGalleryChangedEventReceived[] = "gallery_changed_event_received"; 63 const char kGalleryChangedEventReceived[] = "gallery_changed_event_received";
64 const char kGetAllGalleryWatchResultB[] = 64 const char kGetAllGalleryWatchResultB[] =
65 "watchers_for_galleries_{1, 2, 3}_found"; 65 "watchers_for_galleries_{1, 2, 3}_found";
66 #endif // defined(OS_WIN) 66 #endif // defined(OS_WIN) || defined(OS_LINUX)
67 #endif // !defined(OS_CHROMEOS) 67 #endif // !defined(OS_CHROMEOS)
68 68
69 } // namespace 69 } // namespace
70 70
71 71
72 /////////////////////////////////////////////////////////////////////////////// 72 ///////////////////////////////////////////////////////////////////////////////
73 // MediaGalleriesPrivateGalleryWatchApiTest // 73 // MediaGalleriesPrivateGalleryWatchApiTest //
74 /////////////////////////////////////////////////////////////////////////////// 74 ///////////////////////////////////////////////////////////////////////////////
75 75
76 class MediaGalleriesPrivateGalleryWatchApiTest : public ExtensionApiTest { 76 class MediaGalleriesPrivateGalleryWatchApiTest : public ExtensionApiTest {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 return extensions::ExtensionSystem::Get(browser()->profile())-> 122 return extensions::ExtensionSystem::Get(browser()->profile())->
123 process_manager()->GetBackgroundHostForExtension(extension->id())-> 123 process_manager()->GetBackgroundHostForExtension(extension->id())->
124 render_view_host(); 124 render_view_host();
125 } 125 }
126 126
127 private: 127 private:
128 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesPrivateGalleryWatchApiTest); 128 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesPrivateGalleryWatchApiTest);
129 }; 129 };
130 130
131 131
132 /////////////////////////////////////////////////////////////////////////////// 132 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS))
133 // TESTS //
134 ///////////////////////////////////////////////////////////////////////////////
135 #if defined(OS_WIN)
136 IN_PROC_BROWSER_TEST_F(MediaGalleriesPrivateGalleryWatchApiTest, 133 IN_PROC_BROWSER_TEST_F(MediaGalleriesPrivateGalleryWatchApiTest,
137 BasicGalleryWatch) { 134 BasicGalleryWatch) {
138 EnsureMediaDirectoriesExists media_directories; 135 EnsureMediaDirectoriesExists media_directories;
139 content::RenderViewHost* host = GetBackgroundHostForTestExtension(); 136 content::RenderViewHost* host = GetBackgroundHostForTestExtension();
140 ASSERT_TRUE(host); 137 ASSERT_TRUE(host);
141 138
142 // Get media file systems. 139 // Get media file systems.
143 ExtensionTestMessageListener get_media_systems_finished( 140 ExtensionTestMessageListener get_media_systems_finished(
144 kGetMediaFileSystemsCallbackOK, false /* no reply */); 141 kGetMediaFileSystemsCallbackOK, false /* no reply */);
145 ExecuteCmdAndCheckReply(host, kGetMediaFileSystemsCmd, 142 ExecuteCmdAndCheckReply(host, kGetMediaFileSystemsCmd,
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 kRemoveAllGalleryWatchOK); 368 kRemoveAllGalleryWatchOK);
372 369
373 // Gallery watchers removed. chrome.mediaGalleriesPrivate.getAllGalleryWatch 370 // Gallery watchers removed. chrome.mediaGalleriesPrivate.getAllGalleryWatch
374 // should return an empty list. 371 // should return an empty list.
375 ExtensionTestMessageListener final_get_all_check_finished( 372 ExtensionTestMessageListener final_get_all_check_finished(
376 kGetAllGalleryWatchResultA, false /* no reply */); 373 kGetAllGalleryWatchResultA, false /* no reply */);
377 ExecuteCmdAndCheckReply(host, kGetAllWatchedGalleryIdsCmd, 374 ExecuteCmdAndCheckReply(host, kGetAllWatchedGalleryIdsCmd,
378 kGetAllGalleryWatchOK); 375 kGetAllGalleryWatchOK);
379 EXPECT_TRUE(final_get_all_check_finished.WaitUntilSatisfied()); 376 EXPECT_TRUE(final_get_all_check_finished.WaitUntilSatisfied());
380 } 377 }
381 #endif 378 #endif // defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS))
382 379
383 #if !defined(OS_WIN) && !defined(OS_CHROMEOS) 380 #if defined(OS_MACOSX)
384 // Gallery watch request is not enabled on non-windows platforms. 381 // Gallery watch request is not enabled on Mac: crbug.com/144491.
385 // Please refer to crbug.com/144491.
386 IN_PROC_BROWSER_TEST_F(MediaGalleriesPrivateGalleryWatchApiTest, 382 IN_PROC_BROWSER_TEST_F(MediaGalleriesPrivateGalleryWatchApiTest,
387 SetupGalleryWatch) { 383 SetupGalleryWatch) {
388 EnsureMediaDirectoriesExists media_directories; 384 EnsureMediaDirectoriesExists media_directories;
389 content::RenderViewHost* host = GetBackgroundHostForTestExtension(); 385 content::RenderViewHost* host = GetBackgroundHostForTestExtension();
390 ASSERT_TRUE(host); 386 ASSERT_TRUE(host);
391 387
392 // Get media file systems. 388 // Get media file systems.
393 ExtensionTestMessageListener get_media_systems_finished( 389 ExtensionTestMessageListener get_media_systems_finished(
394 kGetMediaFileSystemsCallbackOK, false /* no reply */); 390 kGetMediaFileSystemsCallbackOK, false /* no reply */);
395 ExecuteCmdAndCheckReply(host, kGetMediaFileSystemsCmd, 391 ExecuteCmdAndCheckReply(host, kGetMediaFileSystemsCmd,
396 kGetMediaFileSystemsOK); 392 kGetMediaFileSystemsOK);
397 EXPECT_TRUE(get_media_systems_finished.WaitUntilSatisfied()); 393 EXPECT_TRUE(get_media_systems_finished.WaitUntilSatisfied());
398 394
399 // Set up a invalid gallery watch. 395 // Set up a invalid gallery watch.
400 ExtensionTestMessageListener gallery_watch_request_finished( 396 ExtensionTestMessageListener gallery_watch_request_finished(
401 kAddGalleryWatchRequestFailed, false /* no reply */); 397 kAddGalleryWatchRequestFailed, false /* no reply */);
402 // Set up gallery watch. 398 // Set up gallery watch.
403 ExecuteCmdAndCheckReply(host, kSetupWatchOnValidGalleriesCmd, 399 ExecuteCmdAndCheckReply(host, kSetupWatchOnValidGalleriesCmd,
404 kAddGalleryWatchOK); 400 kAddGalleryWatchOK);
405 EXPECT_TRUE(gallery_watch_request_finished.WaitUntilSatisfied()); 401 EXPECT_TRUE(gallery_watch_request_finished.WaitUntilSatisfied());
406 } 402 }
407 403
408 // Gallery watch request is not enabled on non-windows platforms.
409 // Please refer to crbug.com/144491.
410 IN_PROC_BROWSER_TEST_F(MediaGalleriesPrivateGalleryWatchApiTest, 404 IN_PROC_BROWSER_TEST_F(MediaGalleriesPrivateGalleryWatchApiTest,
411 GetAllGalleryWatch) { 405 GetAllGalleryWatch) {
412 EnsureMediaDirectoriesExists media_directories; 406 EnsureMediaDirectoriesExists media_directories;
413 content::RenderViewHost* host = GetBackgroundHostForTestExtension(); 407 content::RenderViewHost* host = GetBackgroundHostForTestExtension();
414 ASSERT_TRUE(host); 408 ASSERT_TRUE(host);
415 409
416 // Get media file systems. 410 // Get media file systems.
417 ExtensionTestMessageListener get_media_systems_finished( 411 ExtensionTestMessageListener get_media_systems_finished(
418 kGetMediaFileSystemsCallbackOK, false /* no reply */); 412 kGetMediaFileSystemsCallbackOK, false /* no reply */);
419 ExecuteCmdAndCheckReply(host, kGetMediaFileSystemsCmd, 413 ExecuteCmdAndCheckReply(host, kGetMediaFileSystemsCmd,
420 kGetMediaFileSystemsOK); 414 kGetMediaFileSystemsOK);
421 EXPECT_TRUE(get_media_systems_finished.WaitUntilSatisfied()); 415 EXPECT_TRUE(get_media_systems_finished.WaitUntilSatisfied());
422 416
423 // Set up gallery watch. 417 // Set up gallery watch.
424 ExecuteCmdAndCheckReply(host, kSetupWatchOnValidGalleriesCmd, 418 ExecuteCmdAndCheckReply(host, kSetupWatchOnValidGalleriesCmd,
425 kAddGalleryWatchOK); 419 kAddGalleryWatchOK);
426 420
427 // Gallery watchers does not exists. 421 // Gallery watchers does not exists.
428 // chrome.mediaGalleriesPrivate.getAllGalleryWatch should return an empty 422 // chrome.mediaGalleriesPrivate.getAllGalleryWatch should return an empty
429 // list. 423 // list.
430 ExtensionTestMessageListener get_all_gallery_watch_finished( 424 ExtensionTestMessageListener get_all_gallery_watch_finished(
431 kGetAllGalleryWatchResultA, false /* no reply */); 425 kGetAllGalleryWatchResultA, false /* no reply */);
432 ExecuteCmdAndCheckReply(host, kGetAllWatchedGalleryIdsCmd, 426 ExecuteCmdAndCheckReply(host, kGetAllWatchedGalleryIdsCmd,
433 kGetAllGalleryWatchOK); 427 kGetAllGalleryWatchOK);
434 EXPECT_TRUE(get_all_gallery_watch_finished.WaitUntilSatisfied()); 428 EXPECT_TRUE(get_all_gallery_watch_finished.WaitUntilSatisfied());
435 } 429 }
436 #endif 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