| 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/test/base/in_process_browser_test.h" | 5 #include "chrome/test/base/in_process_browser_test.h" |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/threading/sequenced_worker_pool.h" | 10 #include "base/threading/sequenced_worker_pool.h" |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 std::vector<linked_ptr<Event> > events = GetEvents(); | 267 std::vector<linked_ptr<Event> > events = GetEvents(); |
| 268 | 268 |
| 269 CheckExtensionEvents(expected_event_types, extension_infos, events); | 269 CheckExtensionEvents(expected_event_types, extension_infos, events); |
| 270 | 270 |
| 271 // There will be an additional field: The unload reason. | 271 // There will be an additional field: The unload reason. |
| 272 int unload_reason = -1; | 272 int unload_reason = -1; |
| 273 ASSERT_TRUE(events[2]->data()->GetInteger("unloadReason", &unload_reason)); | 273 ASSERT_TRUE(events[2]->data()->GetInteger("unloadReason", &unload_reason)); |
| 274 ASSERT_EQ(extension_misc::UNLOAD_REASON_UPDATE, unload_reason); | 274 ASSERT_EQ(extension_misc::UNLOAD_REASON_UPDATE, unload_reason); |
| 275 } | 275 } |
| 276 | 276 |
| 277 IN_PROC_BROWSER_TEST_F(PerformanceMonitorBrowserTest, UninstallExtensionEvent) { |
| 278 const int kNumEvents = 3; |
| 279 FilePath extension_path; |
| 280 PathService::Get(chrome::DIR_TEST_DATA, &extension_path); |
| 281 extension_path = extension_path.AppendASCII("performance_monitor") |
| 282 .AppendASCII("extensions") |
| 283 .AppendASCII("simple_extension_v1"); |
| 284 const Extension* extension = LoadExtension(extension_path); |
| 285 |
| 286 std::vector<ExtensionBasicInfo> extension_infos; |
| 287 // There will be three events in all, each pertaining to the same extension: |
| 288 // Extension Install |
| 289 // Extension Disable (Unload) |
| 290 // Extension Uninstall |
| 291 for (int i = 0; i < kNumEvents; ++i) |
| 292 extension_infos.push_back(ExtensionBasicInfo(extension)); |
| 293 |
| 294 UninstallExtension(extension->id()); |
| 295 |
| 296 std::vector<int> expected_event_types; |
| 297 expected_event_types.push_back(EVENT_EXTENSION_INSTALL); |
| 298 expected_event_types.push_back(EVENT_EXTENSION_UNLOAD); |
| 299 expected_event_types.push_back(EVENT_EXTENSION_UNINSTALL); |
| 300 |
| 301 std::vector<linked_ptr<Event> > events = GetEvents(); |
| 302 |
| 303 CheckExtensionEvents(expected_event_types, extension_infos, events); |
| 304 |
| 305 // There will be an additional field: The unload reason. |
| 306 int unload_reason = -1; |
| 307 ASSERT_TRUE(events[1]->data()->GetInteger("unloadReason", &unload_reason)); |
| 308 ASSERT_EQ(extension_misc::UNLOAD_REASON_UNINSTALL, unload_reason); |
| 309 } |
| 310 |
| 277 // Test is flaky on Windows, see http://crbug.com/135635 | 311 // Test is flaky on Windows, see http://crbug.com/135635 |
| 278 #if defined(OS_WIN) | 312 #if defined(OS_WIN) |
| 279 #define MAYBE_NewVersionEvent DISABLED_NewVersionEvent | 313 #define MAYBE_NewVersionEvent DISABLED_NewVersionEvent |
| 280 #else | 314 #else |
| 281 #define MAYBE_NewVersionEvent NewVersionEvent | 315 #define MAYBE_NewVersionEvent NewVersionEvent |
| 282 #endif | 316 #endif |
| 283 IN_PROC_BROWSER_TEST_F(PerformanceMonitorBrowserTest, MAYBE_NewVersionEvent) { | 317 IN_PROC_BROWSER_TEST_F(PerformanceMonitorBrowserTest, MAYBE_NewVersionEvent) { |
| 284 const char kOldVersion[] = "0.0"; | 318 const char kOldVersion[] = "0.0"; |
| 285 | 319 |
| 286 content::BrowserThread::PostBlockingPoolSequencedTask( | 320 content::BrowserThread::PostBlockingPoolSequencedTask( |
| (...skipping 24 matching lines...) Expand all Loading... |
| 311 std::string previous_version; | 345 std::string previous_version; |
| 312 std::string current_version; | 346 std::string current_version; |
| 313 | 347 |
| 314 ASSERT_TRUE(value->GetString("previousVersion", &previous_version)); | 348 ASSERT_TRUE(value->GetString("previousVersion", &previous_version)); |
| 315 ASSERT_EQ(kOldVersion, previous_version); | 349 ASSERT_EQ(kOldVersion, previous_version); |
| 316 ASSERT_TRUE(value->GetString("currentVersion", ¤t_version)); | 350 ASSERT_TRUE(value->GetString("currentVersion", ¤t_version)); |
| 317 ASSERT_EQ(version_string, current_version); | 351 ASSERT_EQ(version_string, current_version); |
| 318 } | 352 } |
| 319 | 353 |
| 320 } // namespace performance_monitor | 354 } // namespace performance_monitor |
| OLD | NEW |