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 // 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_system.h" | 14 #include "chrome/browser/extensions/extension_system.h" |
15 #include "chrome/browser/extensions/extension_test_message_listener.h" | 15 #include "chrome/browser/extensions/extension_test_message_listener.h" |
16 #include "chrome/browser/media_galleries/media_galleries_test_util.h" | 16 #include "chrome/browser/media_galleries/media_galleries_test_util.h" |
17 #include "chrome/common/chrome_paths.h" | 17 #include "chrome/common/chrome_paths.h" |
18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
19 #include "chrome/common/extensions/extension.h" | 19 #include "chrome/common/extensions/extension.h" |
20 #include "content/public/browser/render_view_host.h" | 20 #include "content/public/browser/render_view_host.h" |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 // Id of test extension from | 24 // Id of test extension from |
25 // chrome/test/data/extensions/api_test/|kTestExtensionPath| | 25 // chrome/test/data/extensions/api_test/|kTestExtensionPath| |
26 const char kTestExtensionId[] = "gceegfkgibmgpfopknlcgleimclbknie"; | 26 const char kTestExtensionId[] = "gceegfkgibmgpfopknlcgleimclbknie"; |
27 const char kTestExtensionPath[] = "media_galleries_private/gallerywatch"; | 27 const char kTestExtensionPath[] = "media_galleries_private/gallerywatch"; |
28 | 28 |
29 // JS commands. | 29 // JS commands. |
30 const char kAddGalleryChangedListenerCmd[] = "addGalleryChangedListener()"; | |
31 const char kGetAllWatchedGalleryIdsCmd[] = "getAllWatchedGalleryIds()"; | 30 const char kGetAllWatchedGalleryIdsCmd[] = "getAllWatchedGalleryIds()"; |
32 const char kGetMediaFileSystemsCmd[] = "getMediaFileSystems()"; | 31 const char kGetMediaFileSystemsCmd[] = "getMediaFileSystems()"; |
| 32 const char kSetupWatchOnValidGalleriesCmd[] = "setupWatchOnValidGalleries()"; |
| 33 #if defined(OS_WIN) |
| 34 const char kAddGalleryChangedListenerCmd[] = "addGalleryChangedListener()"; |
33 const char kRemoveAllGalleryWatchCmd[] = "removeAllGalleryWatch()"; | 35 const char kRemoveAllGalleryWatchCmd[] = "removeAllGalleryWatch()"; |
34 const char kRemoveGalleryChangedListenerCmd[] = | 36 const char kRemoveGalleryChangedListenerCmd[] = |
35 "removeGalleryChangedListener()"; | 37 "removeGalleryChangedListener()"; |
36 const char kRemoveGalleryWatchCmd[] = "removeGalleryWatch()"; | 38 const char kRemoveGalleryWatchCmd[] = "removeGalleryWatch()"; |
37 const char kSetupWatchOnValidGalleriesCmd[] = "setupWatchOnValidGalleries()"; | |
38 const char kSetupWatchOnInvalidGalleryCmd[] = "setupWatchOnInvalidGallery()"; | 39 const char kSetupWatchOnInvalidGalleryCmd[] = "setupWatchOnInvalidGallery()"; |
| 40 #endif // defined(OS_WIN) |
39 | 41 |
40 // And JS reply messages. | 42 // And JS reply messages. |
41 const char kAddGalleryWatchOK[] = "add_gallery_watch_ok"; | 43 const char kAddGalleryWatchOK[] = "add_gallery_watch_ok"; |
42 const char kAddGalleryChangedListenerOK[] = "add_gallery_changed_listener_ok"; | |
43 const char kGetAllGalleryWatchOK[] = "get_all_gallery_watch_ok"; | 44 const char kGetAllGalleryWatchOK[] = "get_all_gallery_watch_ok"; |
44 const char kGetMediaFileSystemsOK[] = "get_media_file_systems_ok"; | |
45 const char kGetMediaFileSystemsCallbackOK[] = | 45 const char kGetMediaFileSystemsCallbackOK[] = |
46 "get_media_file_systems_callback_ok"; | 46 "get_media_file_systems_callback_ok"; |
| 47 const char kGetMediaFileSystemsOK[] = "get_media_file_systems_ok"; |
| 48 #if defined(OS_WIN) |
| 49 const char kAddGalleryChangedListenerOK[] = "add_gallery_changed_listener_ok"; |
47 const char kRemoveAllGalleryWatchOK[] = "remove_all_gallery_watch_ok"; | 50 const char kRemoveAllGalleryWatchOK[] = "remove_all_gallery_watch_ok"; |
48 const char kRemoveGalleryChangedListenerOK[] = | 51 const char kRemoveGalleryChangedListenerOK[] = |
49 "remove_gallery_changed_listener_ok"; | 52 "remove_gallery_changed_listener_ok"; |
50 const char kRemoveGalleryWatchOK[] = "remove_gallery_watch_ok"; | 53 const char kRemoveGalleryWatchOK[] = "remove_gallery_watch_ok"; |
| 54 #endif // defined(OS_WIN) |
51 | 55 |
52 // Test reply messages. | 56 // Test reply messages. |
| 57 const char kGetAllGalleryWatchResultA[] = "gallery_watchers_does_not_exists"; |
| 58 const char kAddGalleryWatchRequestFailed[] = "add_watch_request_failed"; |
| 59 #if defined(OS_WIN) |
53 const char kAddGalleryWatchRequestSucceeded[] = "add_watch_request_succeeded"; | 60 const char kAddGalleryWatchRequestSucceeded[] = "add_watch_request_succeeded"; |
54 const char kAddGalleryWatchRequestFailed[] = "add_watch_request_failed"; | |
55 const char kGalleryChangedEventReceived[] = "gallery_changed_event_received"; | 61 const char kGalleryChangedEventReceived[] = "gallery_changed_event_received"; |
56 const char kGetAllGalleryWatchResultA[] = "gallery_watchers_does_not_exists"; | |
57 const char kGetAllGalleryWatchResultB[] = | 62 const char kGetAllGalleryWatchResultB[] = |
58 "watchers_for_galleries_{1, 2, 3}_found"; | 63 "watchers_for_galleries_{1, 2, 3}_found"; |
| 64 #endif // defined(OS_WIN) |
59 | 65 |
60 } // namespace | 66 } // namespace |
61 | 67 |
62 | 68 |
63 /////////////////////////////////////////////////////////////////////////////// | 69 /////////////////////////////////////////////////////////////////////////////// |
64 // MediaGalleriesPrivateGalleryWatchApiTest // | 70 // MediaGalleriesPrivateGalleryWatchApiTest // |
65 /////////////////////////////////////////////////////////////////////////////// | 71 /////////////////////////////////////////////////////////////////////////////// |
66 | 72 |
67 class MediaGalleriesPrivateGalleryWatchApiTest : public ExtensionApiTest { | 73 class MediaGalleriesPrivateGalleryWatchApiTest : public ExtensionApiTest { |
68 public: | 74 public: |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 // Gallery watchers does not exists. | 423 // Gallery watchers does not exists. |
418 // chrome.mediaGalleriesPrivate.getAllGalleryWatch should return an empty | 424 // chrome.mediaGalleriesPrivate.getAllGalleryWatch should return an empty |
419 // list. | 425 // list. |
420 ExtensionTestMessageListener get_all_gallery_watch_finished( | 426 ExtensionTestMessageListener get_all_gallery_watch_finished( |
421 kGetAllGalleryWatchResultA, false /* no reply */); | 427 kGetAllGalleryWatchResultA, false /* no reply */); |
422 ExecuteCmdAndCheckReply(host, kGetAllWatchedGalleryIdsCmd, | 428 ExecuteCmdAndCheckReply(host, kGetAllWatchedGalleryIdsCmd, |
423 kGetAllGalleryWatchOK); | 429 kGetAllGalleryWatchOK); |
424 EXPECT_TRUE(get_all_gallery_watch_finished.WaitUntilSatisfied()); | 430 EXPECT_TRUE(get_all_gallery_watch_finished.WaitUntilSatisfied()); |
425 } | 431 } |
426 #endif | 432 #endif |
OLD | NEW |