Update CrOS OOBE throbber to MD throbber; delete old asset
[chromium-blink-merge.git] / chrome / installer / gcapi / gcapi_test.cc
blobbe649f0612ca55be6972d252204badc98eb9c334
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include <stdio.h>
7 #include "base/at_exit.h"
8 #include "base/command_line.h"
9 #include "chrome/installer/gcapi/gcapi.h"
10 #include "testing/gtest/include/gtest/gtest.h"
12 void call_statically() {
13 DWORD reason = 0;
14 BOOL result_flag_on = FALSE;
15 BOOL result_flag_off = FALSE;
17 // running this twice verifies that the first call does not set
18 // a flag that would make the second fail. Thus, the results
19 // of the two calls should be the same (no state should have changed)
20 result_flag_off = GoogleChromeCompatibilityCheck(
21 FALSE, GCAPI_INVOKED_STANDARD_SHELL, &reason);
22 result_flag_on = GoogleChromeCompatibilityCheck(
23 TRUE, GCAPI_INVOKED_STANDARD_SHELL, &reason);
25 if (result_flag_off != result_flag_on)
26 printf("Registry key flag is not being set properly.");
28 printf("Static call returned result as %d and reason as %ld.\n",
29 result_flag_on, reason);
32 void call_dynamically() {
33 HMODULE module = LoadLibrary(L"gcapi_dll.dll");
34 if (module == NULL) {
35 printf("Couldn't load gcapi_dll.dll.\n");
36 return;
39 GCCC_CompatibilityCheck gccfn = (GCCC_CompatibilityCheck) GetProcAddress(
40 module, "GoogleChromeCompatibilityCheck");
41 if (gccfn != NULL) {
42 DWORD reason = 0;
44 // running this twice verifies that the first call does not set
45 // a flag that would make the second fail. Thus, the results
46 // of the two calls should be the same (no state should have changed)
47 BOOL result_flag_off = gccfn(FALSE, GCAPI_INVOKED_STANDARD_SHELL, &reason);
48 BOOL result_flag_on = gccfn(TRUE, GCAPI_INVOKED_STANDARD_SHELL, &reason);
50 if (result_flag_off != result_flag_on)
51 printf("Registry key flag is not being set properly.");
53 printf("Dynamic call returned result as %d and reason as %ld.\n",
54 result_flag_on, reason);
55 } else {
56 printf("Couldn't find GoogleChromeCompatibilityCheck() in gcapi_dll.\n");
58 FreeLibrary(module);
61 const char kManualLaunchTests[] = "launch-chrome";
63 int main(int argc, char* argv[]) {
64 base::AtExitManager exit_manager;
65 base::CommandLine::Init(argc, argv);
67 testing::InitGoogleTest(&argc, argv);
68 RUN_ALL_TESTS();
70 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kManualLaunchTests)) {
71 call_dynamically();
72 call_statically();
73 printf("LaunchChrome returned %d.\n", LaunchGoogleChrome());