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

Side by Side Diff: ash/test/test_metro_viewer_process_host.cc

Issue 12096064: Automatic Win8 default browser registration for the ash unittests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CHECK->ASSERT_TRUE Created 7 years, 10 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 | « ash/test/test_metro_viewer_process_host.h ('k') | ash/test/test_suite.cc » ('j') | 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #include "ash/test/test_metro_viewer_process_host.h" 5 #include "ash/test/test_metro_viewer_process_host.h"
6 6
7 #include <shellapi.h> 7 #include <shellapi.h>
8 #include <shlobj.h> 8 #include <shlobj.h>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 TestMetroViewerProcessHost::~TestMetroViewerProcessHost() { 55 TestMetroViewerProcessHost::~TestMetroViewerProcessHost() {
56 channel_.reset(); 56 channel_.reset();
57 ipc_thread_.Stop(); 57 ipc_thread_.Stop();
58 } 58 }
59 59
60 void TestMetroViewerProcessHost::NotifyChannelConnected() { 60 void TestMetroViewerProcessHost::NotifyChannelConnected() {
61 channel_connected_event_.Signal(); 61 channel_connected_event_.Signal();
62 } 62 }
63 63
64 bool TestMetroViewerProcessHost::LaunchImmersiveChromeAndWaitForConnection() { 64 bool TestMetroViewerProcessHost::LaunchViewerAndWaitForConnection(
65 // Activate metro chrome. NOTE: This assumes a few things: 65 const string16& app_user_model_id) {
66 // 1) That we are using the per-user AppModelId. This is safe for tests. 66 // Activate the viewer process. NOTE: This assumes that the viewer process is
67 // 67 // registered as the default browser using the provided |app_user_model_id|.
68 // 2) That Chrome is registered as the default browser using a test AppModelId
69 // suffix.
70 // TODO(robertshield,grt): Automate 2). Note that at current, The Way to
71 // register chrome.exe is to run
72 //
73 // setup.exe --register-dev-chrome --register-dev-chrome-suffix=.test
74 //
75 // 3) That chrome.exe/delegate_execute.exe are at all suitable for using as
76 // a metro viewer process for tests.
77 // TODO(robertshield): Investigate having a minimal non-chrome viewer process.
78 // http://crbug.com/170425
79 #if defined(GOOGLE_CHROME_BUILD)
80 const wchar_t kAppUserModelId[] = L"Chrome";
81 #else // GOOGLE_CHROME_BUILD
82 const wchar_t kAppUserModelId[] = L"Chromium";
83 #endif // GOOGLE_CHROME_BUILD
84 68
85 // TODO(robertshield): Initialize COM at test suite startup. 69 // TODO(robertshield): Initialize COM at test suite startup.
86 base::win::ScopedCOMInitializer com_initializer; 70 base::win::ScopedCOMInitializer com_initializer;
87 71
88 string16 app_model_id(kAppUserModelId);
89 app_model_id.append(L".test");
90
91 base::win::ScopedComPtr<IApplicationActivationManager> activator; 72 base::win::ScopedComPtr<IApplicationActivationManager> activator;
92 HRESULT hr = activator.CreateInstance(CLSID_ApplicationActivationManager); 73 HRESULT hr = activator.CreateInstance(CLSID_ApplicationActivationManager);
93 if (SUCCEEDED(hr)) { 74 if (SUCCEEDED(hr)) {
94 DWORD pid = 0; 75 DWORD pid = 0;
95 hr = activator->ActivateApplication( 76 hr = activator->ActivateApplication(
96 app_model_id.c_str(), L"open", AO_NONE, &pid); 77 app_user_model_id.c_str(), L"open", AO_NONE, &pid);
97 } 78 }
98 79
99 LOG_IF(ERROR, FAILED(hr)) << "Tried and failed to launch Metro Chrome. " 80 LOG_IF(ERROR, FAILED(hr)) << "Tried and failed to launch Metro Chrome. "
100 << "hr=" << std::hex << hr; 81 << "hr=" << std::hex << hr;
101 82
102 // Having launched the viewer process, now we wait for it to connect. 83 // Having launched the viewer process, now we wait for it to connect.
103 return channel_connected_event_.TimedWait(base::TimeDelta::FromSeconds(60)); 84 return channel_connected_event_.TimedWait(base::TimeDelta::FromSeconds(60));
104 } 85 }
105 86
106 bool TestMetroViewerProcessHost::Send(IPC::Message* msg) { 87 bool TestMetroViewerProcessHost::Send(IPC::Message* msg) {
(...skipping 25 matching lines...) Expand all
132 backing_surface.reset(new AcceleratedSurface(hwnd)); 113 backing_surface.reset(new AcceleratedSurface(hwnd));
133 114
134 scoped_refptr<AcceleratedPresenter> any_window = 115 scoped_refptr<AcceleratedPresenter> any_window =
135 AcceleratedPresenter::GetForWindow(NULL); 116 AcceleratedPresenter::GetForWindow(NULL);
136 any_window->SetNewTargetWindow(hwnd); 117 any_window->SetNewTargetWindow(hwnd);
137 aura::RemoteRootWindowHostWin::Instance()->Connected(this); 118 aura::RemoteRootWindowHostWin::Instance()->Connected(this);
138 } 119 }
139 120
140 } // namespace test 121 } // namespace test
141 } // namespace ash 122 } // namespace ash
OLDNEW
« no previous file with comments | « ash/test/test_metro_viewer_process_host.h ('k') | ash/test/test_suite.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698