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

Side by Side Diff: chrome/install_static/install_details_unittest.cc

Issue 2422643002: Windows install_static refactor. (Closed)
Patch Set: sync to position 428354 Created 4 years, 1 month 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
OLDNEW
(Empty)
1 // Copyright 2016 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.
4
5 #include "chrome/install_static/install_details.h"
6
7 #include <string>
8
9 #include "base/macros.h"
10 #include "chrome/install_static/install_modes.h"
11 #include "testing/gmock/include/gmock/gmock.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 using ::testing::StrEq;
15
16 namespace install_static {
17
18 class FakeInstallDetails : public InstallDetails {
19 public:
20 FakeInstallDetails() : InstallDetails(&payload) {
21 constants.install_suffix = L"";
22 constants.default_channel_name = L"";
23 constants.supports_multi_install = true;
24 if (kUseGoogleUpdateIntegration) {
25 constants.app_guid = L"testguid";
26 constants.channel_strategy = ChannelStrategy::FIXED;
27 } else {
28 constants.app_guid = L"";
29 constants.channel_strategy = ChannelStrategy::UNSUPPORTED;
30 }
31 payload.mode = &constants;
32 payload.channel = channel.c_str();
33 payload.channel_length = channel.length();
34 }
35
36 InstallConstants constants = InstallConstants();
37 std::wstring channel = std::wstring(L"testchannel");
38 Payload payload = Payload();
39
40 DISALLOW_COPY_AND_ASSIGN(FakeInstallDetails);
41 };
42
43 TEST(InstallDetailsTest, GetClientStateKeyPath) {
44 FakeInstallDetails details;
45 if (kUseGoogleUpdateIntegration) {
46 // Single-install.
47 EXPECT_THAT(details.GetClientStateKeyPath(false),
48 StrEq(L"Software\\Google\\Update\\ClientState\\testguid"));
49 EXPECT_THAT(details.GetClientStateKeyPath(true),
50 StrEq(L"Software\\Google\\Update\\ClientState\\testguid"));
51
52 // Multi-install.
53 details.payload.multi_install = true;
54 EXPECT_THAT(details.GetClientStateKeyPath(false),
55 StrEq(L"Software\\Google\\Update\\ClientState\\testguid"));
56 EXPECT_THAT(details.GetClientStateKeyPath(true),
57 StrEq(std::wstring(L"Software\\Google\\Update\\ClientState\\")
58 .append(kBinariesAppGuid)));
59 } else {
60 // Single-install.
61 EXPECT_THAT(details.GetClientStateKeyPath(false),
62 StrEq(std::wstring(L"Software\\").append(kProductPathName)));
63 EXPECT_THAT(details.GetClientStateKeyPath(true),
64 StrEq(std::wstring(L"Software\\").append(kProductPathName)));
65
66 // Multi-install.
67 details.payload.multi_install = true;
68 EXPECT_THAT(details.GetClientStateKeyPath(false),
69 StrEq(std::wstring(L"Software\\").append(kProductPathName)));
70 EXPECT_THAT(details.GetClientStateKeyPath(true),
71 StrEq(std::wstring(L"Software\\").append(kBinariesPathName)));
72 }
73 }
74
75 TEST(InstallDetailsTest, GetClientStateMediumKeyPath) {
76 FakeInstallDetails details;
77 if (kUseGoogleUpdateIntegration) {
78 // Single-install.
79 EXPECT_THAT(
80 details.GetClientStateMediumKeyPath(false),
81 StrEq(L"Software\\Google\\Update\\ClientStateMedium\\testguid"));
82 EXPECT_THAT(
83 details.GetClientStateMediumKeyPath(true),
84 StrEq(L"Software\\Google\\Update\\ClientStateMedium\\testguid"));
85
86 // Multi-install.
87 details.payload.multi_install = true;
88 EXPECT_THAT(
89 details.GetClientStateMediumKeyPath(false),
90 StrEq(L"Software\\Google\\Update\\ClientStateMedium\\testguid"));
91 EXPECT_THAT(
92 details.GetClientStateMediumKeyPath(true),
93 StrEq(std::wstring(L"Software\\Google\\Update\\ClientStateMedium\\")
94 .append(kBinariesAppGuid)));
95 } else {
96 // Single-install.
97 EXPECT_THAT(details.GetClientStateKeyPath(false),
98 StrEq(std::wstring(L"Software\\").append(kProductPathName)));
99 EXPECT_THAT(details.GetClientStateKeyPath(true),
100 StrEq(std::wstring(L"Software\\").append(kProductPathName)));
101
102 // Multi-install.
103 details.payload.multi_install = true;
104 EXPECT_THAT(details.GetClientStateKeyPath(false),
105 StrEq(std::wstring(L"Software\\").append(kProductPathName)));
106 EXPECT_THAT(details.GetClientStateKeyPath(true),
107 StrEq(std::wstring(L"Software\\").append(kBinariesPathName)));
108 }
109 }
110
111 } // namespace install_static
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698