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

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

Issue 2835233002: Fix integration tests in src/chrome and src/extensions so that we can turn on IO thread checks wi... (Closed)
Patch Set: ready for review Created 3 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
OLDNEW
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/macros.h" 10 #include "base/macros.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/threading/thread_restrictions.h"
13 #include "build/build_config.h" 14 #include "build/build_config.h"
14 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/extensions/extension_apitest.h" 16 #include "chrome/browser/extensions/extension_apitest.h"
16 #include "chrome/browser/media_galleries/media_file_system_registry.h" 17 #include "chrome/browser/media_galleries/media_file_system_registry.h"
17 #include "chrome/browser/media_galleries/media_galleries_preferences.h" 18 #include "chrome/browser/media_galleries/media_galleries_preferences.h"
18 #include "chrome/browser/media_galleries/media_galleries_test_util.h" 19 #include "chrome/browser/media_galleries/media_galleries_test_util.h"
19 #include "chrome/common/chrome_paths.h" 20 #include "chrome/common/chrome_paths.h"
20 #include "content/public/browser/render_frame_host.h" 21 #include "content/public/browser/render_frame_host.h"
21 #include "content/public/browser/render_view_host.h" 22 #include "content/public/browser/render_view_host.h"
22 #include "extensions/browser/process_manager.h" 23 #include "extensions/browser/process_manager.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 103
103 void ExecuteCmdAndCheckReply(const std::string& js_command, 104 void ExecuteCmdAndCheckReply(const std::string& js_command,
104 const std::string& ok_message) { 105 const std::string& ok_message) {
105 ExtensionTestMessageListener listener(ok_message, false); 106 ExtensionTestMessageListener listener(ok_message, false);
106 background_host_->GetMainFrame()->ExecuteJavaScriptForTests( 107 background_host_->GetMainFrame()->ExecuteJavaScriptForTests(
107 base::ASCIIToUTF16(js_command)); 108 base::ASCIIToUTF16(js_command));
108 EXPECT_TRUE(listener.WaitUntilSatisfied()); 109 EXPECT_TRUE(listener.WaitUntilSatisfied());
109 } 110 }
110 111
111 bool AddNewFileInTestGallery() { 112 bool AddNewFileInTestGallery() {
113 base::ThreadRestrictions::ScopedAllowIO allow_io;
112 base::FilePath gallery_file = 114 base::FilePath gallery_file =
113 test_gallery_.GetPath().Append(FILE_PATH_LITERAL("test1.txt")); 115 test_gallery_.GetPath().Append(FILE_PATH_LITERAL("test1.txt"));
114 std::string content("new content"); 116 std::string content("new content");
115 int write_size = 117 int write_size =
116 base::WriteFile(gallery_file, content.c_str(), content.length()); 118 base::WriteFile(gallery_file, content.c_str(), content.length());
117 return (write_size == static_cast<int>(content.length())); 119 return (write_size == static_cast<int>(content.length()));
118 } 120 }
119 121
120 void SetupGalleryWatches() { 122 void SetupGalleryWatches() {
121 std::string expected_result = GalleryWatchesSupported() 123 std::string expected_result = GalleryWatchesSupported()
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 283
282 IN_PROC_BROWSER_TEST_F(MediaGalleriesGalleryWatchApiTest, 284 IN_PROC_BROWSER_TEST_F(MediaGalleriesGalleryWatchApiTest,
283 SetupWatchOnInvalidGallery) { 285 SetupWatchOnInvalidGallery) {
284 // Add gallery watch listener. 286 // Add gallery watch listener.
285 ExecuteCmdAndCheckReply(kAddGalleryChangedListenerCmd, 287 ExecuteCmdAndCheckReply(kAddGalleryChangedListenerCmd,
286 kAddGalleryChangedListenerOK); 288 kAddGalleryChangedListenerOK);
287 // Set up a invalid gallery watch. 289 // Set up a invalid gallery watch.
288 ExecuteCmdAndCheckReply( 290 ExecuteCmdAndCheckReply(
289 kSetupWatchOnInvalidGalleryCmd, kAddGalleryWatchRequestFailed); 291 kSetupWatchOnInvalidGalleryCmd, kAddGalleryWatchRequestFailed);
290 } 292 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698