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

Unified Diff: chrome/browser/chromeos/update_browsertest.cc

Issue 2859043: Added system notification for update_engine. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: . Created 10 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/cros/update_library.cc ('k') | chrome/browser/chromeos/update_observer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/update_browsertest.cc
diff --git a/chrome/browser/chromeos/update_browsertest.cc b/chrome/browser/chromeos/update_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9dca0bb52d932e181cb781d1808f84e8e1016adc
--- /dev/null
+++ b/chrome/browser/chromeos/update_browsertest.cc
@@ -0,0 +1,121 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/ref_counted.h"
+#include "base/utf_string_conversions.h"
+#include "chrome/test/automation/dom_element_proxy.h"
+#include "chrome/browser/browser.h"
+#include "chrome/browser/browser_list.h"
+#include "chrome/browser/chromeos/update_observer.h"
+#include "chrome/browser/chromeos/cros/mock_update_library.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/common/url_constants.h"
+#include "chrome/test/in_process_browser_test.h"
+#include "chrome/test/ui_test_utils.h"
+
+using ::testing::AnyNumber;
+using ::testing::InvokeWithoutArgs;
+using ::testing::Return;
+using ::testing::ReturnRef;
+using ::testing::_;
+using ::testing::Invoke;
+using ::testing::Exactly;
+
+namespace {
+
+typedef ObserverList<chromeos::UpdateLibrary::Observer> Observers;
+
+void CallObservers(chromeos::MockUpdateLibrary* lib,
+ Observers* observers,
+ const chromeos::UpdateLibrary::Status& x) {
+ EXPECT_CALL(*lib, status())
+ .Times(AnyNumber())
+ .WillRepeatedly((ReturnRef(x)))
+ .RetiresOnSaturation();
+ FOR_EACH_OBSERVER(chromeos::UpdateLibrary::Observer, *observers,
+ Changed(lib));
+}
+
+void FireSuccessSequence(chromeos::MockUpdateLibrary* lib,
+ Observers* observer) {
+ chromeos::UpdateLibrary::Status status;
+
+ status.status = chromeos::UPDATE_STATUS_IDLE;
+ CallObservers(lib, observer, status);
+
+ status.status = chromeos::UPDATE_STATUS_CHECKING_FOR_UPDATE;
+ CallObservers(lib, observer, status);
+
+ status.status = chromeos::UPDATE_STATUS_UPDATE_AVAILABLE;
+ CallObservers(lib, observer, status);
+
+ status.status = chromeos::UPDATE_STATUS_DOWNLOADING;
+ status.download_progress = 10;
+ CallObservers(lib, observer, status);
+
+ status.status = chromeos::UPDATE_STATUS_DOWNLOADING;
+ status.download_progress = 50;
+ CallObservers(lib, observer, status);
+
+ status.status = chromeos::UPDATE_STATUS_DOWNLOADING;
+ status.download_progress = 90;
+ CallObservers(lib, observer, status);
+
+ status.status = chromeos::UPDATE_STATUS_VERIFYING;
+ CallObservers(lib, observer, status);
+
+ status.status = chromeos::UPDATE_STATUS_FINALIZING;
+ CallObservers(lib, observer, status);
+
+ status.status = chromeos::UPDATE_STATUS_UPDATED_NEED_REBOOT;
+ CallObservers(lib, observer, status);
+}
+
+void FireFailureSequence(chromeos::MockUpdateLibrary* lib,
+ Observers* observer) {
+ chromeos::UpdateLibrary::Status status;
+
+ status.status = chromeos::UPDATE_STATUS_IDLE;
+ CallObservers(lib, observer, status);
+
+ status.status = chromeos::UPDATE_STATUS_CHECKING_FOR_UPDATE;
+ CallObservers(lib, observer, status);
+
+ status.status = chromeos::UPDATE_STATUS_UPDATE_AVAILABLE;
+ CallObservers(lib, observer, status);
+
+ status.status = chromeos::UPDATE_STATUS_DOWNLOADING;
+ status.download_progress = 10;
+ CallObservers(lib, observer, status);
+
+ status.status = chromeos::UPDATE_STATUS_ERROR;
+ status.download_progress = 10;
+ CallObservers(lib, observer, status);
+}
+
+class UpdateBrowserTest : public InProcessBrowserTest {
+ public:
+ UpdateBrowserTest() {}
+};
+
+IN_PROC_BROWSER_TEST_F(UpdateBrowserTest, Notifications) {
+ scoped_ptr<chromeos::MockUpdateLibrary> lib(
+ new chromeos::MockUpdateLibrary());
+
+ Observers observers;
+
+ EXPECT_CALL(*lib, AddObserver(_))
+ .WillRepeatedly(Invoke(&observers,
+ &Observers::AddObserver));
+
+ chromeos::UpdateObserver* observe =
+ new chromeos::UpdateObserver(browser()->profile());
+ lib->AddObserver(observe);
+
+ FireSuccessSequence(lib.get(), &observers);
+ FireFailureSequence(lib.get(), &observers);
+}
+
+} // namespace
+
« no previous file with comments | « chrome/browser/chromeos/cros/update_library.cc ('k') | chrome/browser/chromeos/update_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698