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

Side by Side Diff: chrome/installer/gcapi/gcapi_test.cc

Issue 9465013: Mike's change. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing Roger's feedback. Created 8 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 | « chrome/installer/gcapi/gcapi_reactivation_test.cc ('k') | 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <stdio.h> 5 #include <stdio.h>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/installer/gcapi/gcapi.h" 8 #include "chrome/installer/gcapi/gcapi.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 void call_statically() { 11 void call_statically() {
12 DWORD reason = 0; 12 DWORD reason = 0;
13 BOOL result_flag_on = FALSE; 13 BOOL result_flag_on = FALSE;
14 BOOL result_flag_off = FALSE; 14 BOOL result_flag_off = FALSE;
15 15
16 // running this twice verifies that the first call does not set 16 // running this twice verifies that the first call does not set
17 // a flag that would make the second fail. Thus, the results 17 // a flag that would make the second fail. Thus, the results
18 // of the two calls should be the same (no state should have changed) 18 // of the two calls should be the same (no state should have changed)
19 result_flag_off = GoogleChromeCompatibilityCheck(FALSE, &reason); 19 result_flag_off = GoogleChromeCompatibilityCheck(
20 result_flag_on = GoogleChromeCompatibilityCheck(TRUE, &reason); 20 FALSE, GCAPI_INVOKED_STANDARD_SHELL, &reason);
21 result_flag_on = GoogleChromeCompatibilityCheck(
22 TRUE, GCAPI_INVOKED_STANDARD_SHELL, &reason);
21 23
22 if (result_flag_off != result_flag_on) 24 if (result_flag_off != result_flag_on)
23 printf("Registry key flag is not being set properly."); 25 printf("Registry key flag is not being set properly.");
24 26
25 printf("Static call returned result as %d and reason as %d.\n", 27 printf("Static call returned result as %d and reason as %d.\n",
26 result_flag_on, reason); 28 result_flag_on, reason);
27 } 29 }
28 30
29 void call_dynamically() { 31 void call_dynamically() {
30 HMODULE module = LoadLibrary(L"gcapi_dll.dll"); 32 HMODULE module = LoadLibrary(L"gcapi_dll.dll");
31 if (module == NULL) { 33 if (module == NULL) {
32 printf("Couldn't load gcapi_dll.dll.\n"); 34 printf("Couldn't load gcapi_dll.dll.\n");
33 return; 35 return;
34 } 36 }
35 37
36 GCCC_CompatibilityCheck gccfn = (GCCC_CompatibilityCheck) GetProcAddress( 38 GCCC_CompatibilityCheck gccfn = (GCCC_CompatibilityCheck) GetProcAddress(
37 module, "GoogleChromeCompatibilityCheck"); 39 module, "GoogleChromeCompatibilityCheck");
38 if (gccfn != NULL) { 40 if (gccfn != NULL) {
39 DWORD reason = 0; 41 DWORD reason = 0;
40 42
41 // running this twice verifies that the first call does not set 43 // running this twice verifies that the first call does not set
42 // a flag that would make the second fail. Thus, the results 44 // a flag that would make the second fail. Thus, the results
43 // of the two calls should be the same (no state should have changed) 45 // of the two calls should be the same (no state should have changed)
44 BOOL result_flag_off = gccfn(FALSE, &reason); 46 BOOL result_flag_off = gccfn(FALSE, GCAPI_INVOKED_STANDARD_SHELL, &reason);
45 BOOL result_flag_on = gccfn(TRUE, &reason); 47 BOOL result_flag_on = gccfn(TRUE, GCAPI_INVOKED_STANDARD_SHELL, &reason);
46 48
47 if (result_flag_off != result_flag_on) 49 if (result_flag_off != result_flag_on)
48 printf("Registry key flag is not being set properly."); 50 printf("Registry key flag is not being set properly.");
49 51
50 printf("Dynamic call returned result as %d and reason as %d.\n", 52 printf("Dynamic call returned result as %d and reason as %d.\n",
51 result_flag_on, reason); 53 result_flag_on, reason);
52 } else { 54 } else {
53 printf("Couldn't find GoogleChromeCompatibilityCheck() in gcapi_dll.\n"); 55 printf("Couldn't find GoogleChromeCompatibilityCheck() in gcapi_dll.\n");
54 } 56 }
55 FreeLibrary(module); 57 FreeLibrary(module);
56 } 58 }
57 59
58 const char kManualLaunchTests[] = "launch-chrome"; 60 const char kManualLaunchTests[] = "launch-chrome";
59 61
60 int main(int argc, char* argv[]) { 62 int main(int argc, char* argv[]) {
61 CommandLine::Init(argc, argv); 63 CommandLine::Init(argc, argv);
62 64
63 testing::InitGoogleTest(&argc, argv); 65 testing::InitGoogleTest(&argc, argv);
64 RUN_ALL_TESTS(); 66 RUN_ALL_TESTS();
65 67
66 if (CommandLine::ForCurrentProcess()->HasSwitch(kManualLaunchTests)) { 68 if (CommandLine::ForCurrentProcess()->HasSwitch(kManualLaunchTests)) {
67 call_dynamically(); 69 call_dynamically();
68 call_statically(); 70 call_statically();
69 printf("LaunchChrome returned %d.\n", LaunchGoogleChrome()); 71 printf("LaunchChrome returned %d.\n", LaunchGoogleChrome());
70 } 72 }
71 } 73 }
OLDNEW
« no previous file with comments | « chrome/installer/gcapi/gcapi_reactivation_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698