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

Side by Side Diff: apps/app_shim/app_shim_interactive_uitest_mac.mm

Issue 598443002: [Mac] Re-enable AppShimInteractiveTest.Launch. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | 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 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 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 #include <vector> 6 #include <vector>
7 7
8 #include "apps/app_shim/app_shim_handler_mac.h" 8 #include "apps/app_shim/app_shim_handler_mac.h"
9 #include "apps/app_shim/app_shim_host_manager_mac.h" 9 #include "apps/app_shim/app_shim_host_manager_mac.h"
10 #include "apps/app_shim/extension_app_shim_handler_mac.h" 10 #include "apps/app_shim/extension_app_shim_handler_mac.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 base::AutoReset<bool> auto_reset_; 46 base::AutoReset<bool> auto_reset_;
47 47
48 DISALLOW_COPY_AND_ASSIGN(AppShimInteractiveTest); 48 DISALLOW_COPY_AND_ASSIGN(AppShimInteractiveTest);
49 }; 49 };
50 50
51 // Watches for changes to a file. This is designed to be used from the the UI 51 // Watches for changes to a file. This is designed to be used from the the UI
52 // thread. 52 // thread.
53 class WindowedFilePathWatcher 53 class WindowedFilePathWatcher
54 : public base::RefCountedThreadSafe<WindowedFilePathWatcher> { 54 : public base::RefCountedThreadSafe<WindowedFilePathWatcher> {
55 public: 55 public:
56 WindowedFilePathWatcher(const base::FilePath& path) : observed_(false) { 56 WindowedFilePathWatcher(const base::FilePath& path)
57 : path_(path), observed_(false) {
57 content::BrowserThread::PostTask( 58 content::BrowserThread::PostTask(
58 content::BrowserThread::FILE, 59 content::BrowserThread::FILE,
59 FROM_HERE, 60 FROM_HERE,
60 base::Bind(&WindowedFilePathWatcher::Watch, this, path)); 61 base::Bind(&WindowedFilePathWatcher::Watch, this, path.DirName()));
61 } 62 }
62 63
63 void Wait() { 64 void Wait() {
64 if (observed_) 65 if (observed_)
65 return; 66 return;
66 67
67 run_loop_.reset(new base::RunLoop); 68 run_loop_.reset(new base::RunLoop);
68 run_loop_->Run(); 69 run_loop_->Run();
69 } 70 }
70 71
71 protected: 72 protected:
72 friend class base::RefCountedThreadSafe<WindowedFilePathWatcher>; 73 friend class base::RefCountedThreadSafe<WindowedFilePathWatcher>;
73 virtual ~WindowedFilePathWatcher() {} 74 virtual ~WindowedFilePathWatcher() {}
74 75
75 void Watch(const base::FilePath& path) { 76 void Watch(const base::FilePath& path) {
tapted 2014/09/23 06:28:41 I don't think the function argument here is needed
jackhou1 2014/09/23 07:34:07 Done.
76 watcher_.Watch( 77 watcher_.Watch(
77 path, false, base::Bind(&WindowedFilePathWatcher::Observe, this)); 78 path, false, base::Bind(&WindowedFilePathWatcher::Observe, this));
78 } 79 }
79 80
80 void Observe(const base::FilePath& path, bool error) { 81 void Observe(const base::FilePath& path, bool error) {
81 content::BrowserThread::PostTask( 82 DCHECK(!error);
82 content::BrowserThread::UI, 83 if (base::PathExists(path_)) {
83 FROM_HERE, 84 content::BrowserThread::PostTask(
tapted 2014/09/23 06:28:41 watcher_->Cancel() before this? Not entirely sure
jackhou1 2014/09/23 07:34:06 Done.
84 base::Bind(&WindowedFilePathWatcher::StopRunLoop, this)); 85 content::BrowserThread::UI,
86 FROM_HERE,
87 base::Bind(&WindowedFilePathWatcher::StopRunLoop, this));
88 }
85 } 89 }
86 90
87 void StopRunLoop() { 91 void StopRunLoop() {
88 observed_ = true; 92 observed_ = true;
89 if (run_loop_.get()) 93 if (run_loop_.get())
90 run_loop_->Quit(); 94 run_loop_->Quit();
91 } 95 }
92 96
93 private: 97 private:
98 base::FilePath path_;
tapted 2014/09/23 06:28:41 nit: const?
jackhou1 2014/09/23 07:34:06 Done.
94 base::FilePathWatcher watcher_; 99 base::FilePathWatcher watcher_;
95 bool observed_; 100 bool observed_;
96 scoped_ptr<base::RunLoop> run_loop_; 101 scoped_ptr<base::RunLoop> run_loop_;
97 102
98 DISALLOW_COPY_AND_ASSIGN(WindowedFilePathWatcher); 103 DISALLOW_COPY_AND_ASSIGN(WindowedFilePathWatcher);
99 }; 104 };
100 105
101 // Watches for an app shim to connect. 106 // Watches for an app shim to connect.
102 class WindowedAppShimLaunchObserver : public apps::AppShimHandler { 107 class WindowedAppShimLaunchObserver : public apps::AppShimHandler {
103 public: 108 public:
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 212
208 runLoop_.reset(new base::RunLoop); 213 runLoop_.reset(new base::RunLoop);
209 runLoop_->Run(); 214 runLoop_->Run();
210 } 215 }
211 216
212 @end 217 @end
213 218
214 namespace apps { 219 namespace apps {
215 220
216 // Shims require static libraries http://crbug.com/386024. 221 // Shims require static libraries http://crbug.com/386024.
217 // This test is flaky on OSX. http://crbug.com/415422 222 #if defined(COMPONENT_BUILD)
218 #if defined(COMPONENT_BUILD) || defined(OS_MACOSX)
219 #define MAYBE_Launch DISABLED_Launch 223 #define MAYBE_Launch DISABLED_Launch
220 #define MAYBE_RebuildShim DISABLED_RebuildShim 224 #define MAYBE_RebuildShim DISABLED_RebuildShim
221 #else 225 #else
222 #define MAYBE_Launch Launch 226 #define MAYBE_Launch Launch
223 #define MAYBE_RebuildShim RebuildShim 227 #define MAYBE_RebuildShim RebuildShim
224 #endif 228 #endif
225 229
226 // Test that launching the shim for an app starts the app, and vice versa. 230 // Test that launching the shim for an app starts the app, and vice versa.
227 // These two cases are combined because the time to run the test is dominated 231 // These two cases are combined because the time to run the test is dominated
228 // by loading the extension and creating the shim. 232 // by loading the extension and creating the shim.
(...skipping 11 matching lines...) Expand all
240 244
241 // Create the internal app shim by simulating an app update. FilePathWatcher 245 // Create the internal app shim by simulating an app update. FilePathWatcher
242 // is used to wait for file operations on the shim to be finished before 246 // is used to wait for file operations on the shim to be finished before
243 // attempting to launch it. Since all of the file operations are done in the 247 // attempting to launch it. Since all of the file operations are done in the
244 // same event on the FILE thread, everything will be done by the time the 248 // same event on the FILE thread, everything will be done by the time the
245 // watcher's callback is executed. 249 // watcher's callback is executed.
246 scoped_refptr<WindowedFilePathWatcher> file_watcher = 250 scoped_refptr<WindowedFilePathWatcher> file_watcher =
247 new WindowedFilePathWatcher(shim_path); 251 new WindowedFilePathWatcher(shim_path);
248 web_app::UpdateAllShortcuts(base::string16(), profile(), app); 252 web_app::UpdateAllShortcuts(base::string16(), profile(), app);
249 file_watcher->Wait(); 253 file_watcher->Wait();
254 ASSERT_TRUE(base::PathExists(shim_path));
250 NSString* bundle_id = GetBundleID(shim_path); 255 NSString* bundle_id = GetBundleID(shim_path);
251 256
252 // Case 1: Launch the shim, it should start the app. 257 // Case 1: Launch the shim, it should start the app.
253 { 258 {
254 ExtensionTestMessageListener launched_listener("Launched", false); 259 ExtensionTestMessageListener launched_listener("Launched", false);
255 CommandLine shim_cmdline(CommandLine::NO_PROGRAM); 260 CommandLine shim_cmdline(CommandLine::NO_PROGRAM);
256 shim_cmdline.AppendSwitch(app_mode::kLaunchedForTest); 261 shim_cmdline.AppendSwitch(app_mode::kLaunchedForTest);
257 ProcessSerialNumber shim_psn; 262 ProcessSerialNumber shim_psn;
258 ASSERT_TRUE(base::mac::OpenApplicationWithPath( 263 ASSERT_TRUE(base::mac::OpenApplicationWithPath(
259 shim_path, shim_cmdline, kLSLaunchDefaults, &shim_psn)); 264 shim_path, shim_cmdline, kLSLaunchDefaults, &shim_psn));
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 // the shim is rebuilt. 395 // the shim is rebuilt.
391 WindowedAppShimLaunchObserver(app->id()).Wait(); 396 WindowedAppShimLaunchObserver(app->id()).Wait();
392 397
393 EXPECT_TRUE(GetFirstAppWindow()); 398 EXPECT_TRUE(GetFirstAppWindow());
394 EXPECT_TRUE(HasAppShimHost(profile(), app->id())); 399 EXPECT_TRUE(HasAppShimHost(profile(), app->id()));
395 } 400 }
396 401
397 #endif // defined(ARCH_CPU_64_BITS) 402 #endif // defined(ARCH_CPU_64_BITS)
398 403
399 } // namespace apps 404 } // namespace apps
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698