| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // MediaGalleries gallery watch API browser tests. | 5 // MediaGalleries gallery watch API browser tests. |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/files/file_path_watcher.h" | 8 #include "base/files/file_path_watcher.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 ExtensionApiTest::TearDownOnMainThread(); | 101 ExtensionApiTest::TearDownOnMainThread(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 bool GalleryWatchesSupported() { | 104 bool GalleryWatchesSupported() { |
| 105 return base::FilePathWatcher::RecursiveWatchAvailable(); | 105 return base::FilePathWatcher::RecursiveWatchAvailable(); |
| 106 } | 106 } |
| 107 | 107 |
| 108 void ExecuteCmdAndCheckReply(const std::string& js_command, | 108 void ExecuteCmdAndCheckReply(const std::string& js_command, |
| 109 const std::string& ok_message) { | 109 const std::string& ok_message) { |
| 110 ExtensionTestMessageListener listener(ok_message, false); | 110 ExtensionTestMessageListener listener(ok_message, false); |
| 111 background_host_->GetMainFrame()->ExecuteJavaScript( | 111 background_host_->GetMainFrame()->ExecuteJavaScriptForTests( |
| 112 base::ASCIIToUTF16(js_command)); | 112 base::ASCIIToUTF16(js_command)); |
| 113 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 113 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
| 114 } | 114 } |
| 115 | 115 |
| 116 bool AddNewFileInTestGallery() { | 116 bool AddNewFileInTestGallery() { |
| 117 base::FilePath gallery_file = | 117 base::FilePath gallery_file = |
| 118 test_gallery_.path().Append(FILE_PATH_LITERAL("test1.txt")); | 118 test_gallery_.path().Append(FILE_PATH_LITERAL("test1.txt")); |
| 119 std::string content("new content"); | 119 std::string content("new content"); |
| 120 int write_size = | 120 int write_size = |
| 121 base::WriteFile(gallery_file, content.c_str(), content.length()); | 121 base::WriteFile(gallery_file, content.c_str(), content.length()); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 // Remove all gallery watchers. | 351 // Remove all gallery watchers. |
| 352 ExecuteCmdAndCheckReply(kRemoveAllGalleryWatchCmd, kRemoveAllGalleryWatchOK); | 352 ExecuteCmdAndCheckReply(kRemoveAllGalleryWatchCmd, kRemoveAllGalleryWatchOK); |
| 353 | 353 |
| 354 // Gallery watchers removed. chrome.mediaGalleries.getAllGalleryWatch | 354 // Gallery watchers removed. chrome.mediaGalleries.getAllGalleryWatch |
| 355 // should return an empty list. | 355 // should return an empty list. |
| 356 ExtensionTestMessageListener final_get_all_check_finished( | 356 ExtensionTestMessageListener final_get_all_check_finished( |
| 357 kNoGalleryWatchesInstalled, false /* no reply */); | 357 kNoGalleryWatchesInstalled, false /* no reply */); |
| 358 ExecuteCmdAndCheckReply(kGetAllWatchedGalleryIdsCmd, kGetAllGalleryWatchOK); | 358 ExecuteCmdAndCheckReply(kGetAllWatchedGalleryIdsCmd, kGetAllGalleryWatchOK); |
| 359 EXPECT_TRUE(final_get_all_check_finished.WaitUntilSatisfied()); | 359 EXPECT_TRUE(final_get_all_check_finished.WaitUntilSatisfied()); |
| 360 } | 360 } |
| OLD | NEW |