OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/installer/util/product.h" | 5 #include "chrome/installer/util/product.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 EXPECT_EQ(std::wstring::npos, | 54 EXPECT_EQ(std::wstring::npos, |
55 user_data_dir.value().find(program_files.value())); | 55 user_data_dir.value().find(program_files.value())); |
56 | 56 |
57 HKEY root = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 57 HKEY root = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
58 { | 58 { |
59 RegistryOverrideManager override_manager; | 59 RegistryOverrideManager override_manager; |
60 override_manager.OverrideRegistry(root); | 60 override_manager.OverrideRegistry(root); |
61 | 61 |
62 // There should be no installed version in the registry. | 62 // There should be no installed version in the registry. |
63 machine_state.Initialize(); | 63 machine_state.Initialize(); |
64 EXPECT_TRUE(machine_state.GetProductState( | 64 EXPECT_EQ(nullptr, machine_state.GetProductState(system_level)); |
65 system_level, distribution->GetType()) == NULL); | |
66 | 65 |
67 // Let's pretend chrome is installed. | 66 // Let's pretend chrome is installed. |
68 RegKey version_key(root, distribution->GetVersionKey().c_str(), | 67 RegKey version_key(root, distribution->GetVersionKey().c_str(), |
69 KEY_ALL_ACCESS); | 68 KEY_ALL_ACCESS); |
70 ASSERT_TRUE(version_key.Valid()); | 69 ASSERT_TRUE(version_key.Valid()); |
71 | 70 |
72 const char kCurrentVersion[] = "1.2.3.4"; | 71 const char kCurrentVersion[] = "1.2.3.4"; |
73 base::Version current_version(kCurrentVersion); | 72 base::Version current_version(kCurrentVersion); |
74 version_key.WriteValue(google_update::kRegVersionField, | 73 version_key.WriteValue(google_update::kRegVersionField, |
75 base::UTF8ToWide( | 74 base::UTF8ToWide( |
76 current_version.GetString()).c_str()); | 75 current_version.GetString()).c_str()); |
77 | 76 |
78 // We started out with a non-msi product. | 77 // We started out with a non-msi product. |
79 machine_state.Initialize(); | 78 machine_state.Initialize(); |
80 const installer::ProductState* chrome_state = | 79 const installer::ProductState* chrome_state = |
81 machine_state.GetProductState(system_level, distribution->GetType()); | 80 machine_state.GetProductState(system_level); |
82 EXPECT_TRUE(chrome_state != NULL); | 81 EXPECT_NE(nullptr, chrome_state); |
83 if (chrome_state != NULL) { | 82 if (chrome_state) { |
84 EXPECT_EQ(chrome_state->version(), current_version); | 83 EXPECT_EQ(chrome_state->version(), current_version); |
85 EXPECT_FALSE(chrome_state->is_msi()); | 84 EXPECT_FALSE(chrome_state->is_msi()); |
86 } | 85 } |
87 | 86 |
88 // Create a make-believe client state key. | 87 // Create a make-believe client state key. |
89 RegKey key; | 88 RegKey key; |
90 std::wstring state_key_path(distribution->GetStateKey()); | 89 std::wstring state_key_path(distribution->GetStateKey()); |
91 ASSERT_EQ(ERROR_SUCCESS, | 90 ASSERT_EQ(ERROR_SUCCESS, |
92 key.Create(root, state_key_path.c_str(), KEY_ALL_ACCESS)); | 91 key.Create(root, state_key_path.c_str(), KEY_ALL_ACCESS)); |
93 | 92 |
94 // Set the MSI marker, refresh, and verify that we now see the MSI marker. | 93 // Set the MSI marker, refresh, and verify that we now see the MSI marker. |
95 EXPECT_TRUE(product->SetMsiMarker(system_level, true)); | 94 EXPECT_TRUE(product->SetMsiMarker(system_level, true)); |
96 machine_state.Initialize(); | 95 machine_state.Initialize(); |
97 chrome_state = | 96 chrome_state = machine_state.GetProductState(system_level); |
98 machine_state.GetProductState(system_level, distribution->GetType()); | 97 EXPECT_NE(nullptr, chrome_state); |
99 EXPECT_TRUE(chrome_state != NULL); | 98 if (chrome_state) |
100 if (chrome_state != NULL) | |
101 EXPECT_TRUE(chrome_state->is_msi()); | 99 EXPECT_TRUE(chrome_state->is_msi()); |
102 } | 100 } |
103 } | 101 } |
104 | 102 |
105 TEST(ProductTest, LaunchChrome) { | 103 TEST(ProductTest, LaunchChrome) { |
106 // TODO(tommi): Test Product::LaunchChrome and | 104 // TODO(tommi): Test Product::LaunchChrome and |
107 // Product::LaunchChromeAndWait. | 105 // Product::LaunchChromeAndWait. |
108 NOTIMPLEMENTED(); | 106 NOTIMPLEMENTED(); |
109 } | 107 } |
OLD | NEW |