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

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: Cleanup. 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
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::LaunchImmersiveChromeAndWaitForConnection(
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 a few things:
67 // 1) That the viewer process is registered as the default browser using the
68 // provided |app_user_model_id|.
67 // 69 //
68 // 2) That Chrome is registered as the default browser using a test AppModelId 70 // 2) That the viewer process has been built. This process is still chrome.exe
69 // suffix. 71 // at the moment, so a run-time dependency still exists between this code
grt (UTC plus 2) 2013/02/12 15:37:43 If I understand correctly, this code won't have to
robertshield 2013/02/12 16:57:08 Done.
70 // TODO(robertshield,grt): Automate 2). Note that at current, The Way to 72 // and chrome.exe
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. 73 // TODO(robertshield): Investigate having a minimal non-chrome viewer process.
78 // http://crbug.com/170425 74 // 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 75
85 // TODO(robertshield): Initialize COM at test suite startup. 76 // TODO(robertshield): Initialize COM at test suite startup.
86 base::win::ScopedCOMInitializer com_initializer; 77 base::win::ScopedCOMInitializer com_initializer;
87 78
88 string16 app_model_id(kAppUserModelId);
89 app_model_id.append(L".test");
90
91 base::win::ScopedComPtr<IApplicationActivationManager> activator; 79 base::win::ScopedComPtr<IApplicationActivationManager> activator;
92 HRESULT hr = activator.CreateInstance(CLSID_ApplicationActivationManager); 80 HRESULT hr = activator.CreateInstance(CLSID_ApplicationActivationManager);
93 if (SUCCEEDED(hr)) { 81 if (SUCCEEDED(hr)) {
94 DWORD pid = 0; 82 DWORD pid = 0;
95 hr = activator->ActivateApplication( 83 hr = activator->ActivateApplication(
96 app_model_id.c_str(), L"open", AO_NONE, &pid); 84 app_user_model_id.c_str(), L"open", AO_NONE, &pid);
97 } 85 }
98 86
99 LOG_IF(ERROR, FAILED(hr)) << "Tried and failed to launch Metro Chrome. " 87 LOG_IF(ERROR, FAILED(hr)) << "Tried and failed to launch Metro Chrome. "
100 << "hr=" << std::hex << hr; 88 << "hr=" << std::hex << hr;
101 89
102 // Having launched the viewer process, now we wait for it to connect. 90 // Having launched the viewer process, now we wait for it to connect.
103 return channel_connected_event_.TimedWait(base::TimeDelta::FromSeconds(60)); 91 return channel_connected_event_.TimedWait(base::TimeDelta::FromSeconds(60));
104 } 92 }
105 93
106 bool TestMetroViewerProcessHost::Send(IPC::Message* msg) { 94 bool TestMetroViewerProcessHost::Send(IPC::Message* msg) {
(...skipping 25 matching lines...) Expand all
132 backing_surface.reset(new AcceleratedSurface(hwnd)); 120 backing_surface.reset(new AcceleratedSurface(hwnd));
133 121
134 scoped_refptr<AcceleratedPresenter> any_window = 122 scoped_refptr<AcceleratedPresenter> any_window =
135 AcceleratedPresenter::GetForWindow(NULL); 123 AcceleratedPresenter::GetForWindow(NULL);
136 any_window->SetNewTargetWindow(hwnd); 124 any_window->SetNewTargetWindow(hwnd);
137 aura::RemoteRootWindowHostWin::Instance()->Connected(this); 125 aura::RemoteRootWindowHostWin::Instance()->Connected(this);
138 } 126 }
139 127
140 } // namespace test 128 } // namespace test
141 } // namespace ash 129 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698