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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2010 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 "base/ref_counted.h"
6 #include "base/utf_string_conversions.h"
7 #include "chrome/test/automation/dom_element_proxy.h"
8 #include "chrome/browser/browser.h"
9 #include "chrome/browser/browser_list.h"
10 #include "chrome/browser/chromeos/update_observer.h"
11 #include "chrome/browser/chromeos/cros/mock_update_library.h"
12 #include "chrome/browser/tab_contents/tab_contents.h"
13 #include "chrome/common/url_constants.h"
14 #include "chrome/test/in_process_browser_test.h"
15 #include "chrome/test/ui_test_utils.h"
16
17 using ::testing::AnyNumber;
18 using ::testing::InvokeWithoutArgs;
19 using ::testing::Return;
20 using ::testing::ReturnRef;
21 using ::testing::_;
22 using ::testing::Invoke;
23 using ::testing::Exactly;
24
25 namespace {
26
27 typedef ObserverList<chromeos::UpdateLibrary::Observer> Observers;
28
29 void CallObservers(chromeos::MockUpdateLibrary* lib,
30 Observers* observers,
31 const chromeos::UpdateLibrary::Status& x) {
32 EXPECT_CALL(*lib, status())
33 .Times(AnyNumber())
34 .WillRepeatedly((ReturnRef(x)))
35 .RetiresOnSaturation();
36 FOR_EACH_OBSERVER(chromeos::UpdateLibrary::Observer, *observers,
37 Changed(lib));
38 }
39
40 void FireSuccessSequence(chromeos::MockUpdateLibrary* lib,
41 Observers* observer) {
42 chromeos::UpdateLibrary::Status status;
43
44 status.status = chromeos::UPDATE_STATUS_IDLE;
45 CallObservers(lib, observer, status);
46
47 status.status = chromeos::UPDATE_STATUS_CHECKING_FOR_UPDATE;
48 CallObservers(lib, observer, status);
49
50 status.status = chromeos::UPDATE_STATUS_UPDATE_AVAILABLE;
51 CallObservers(lib, observer, status);
52
53 status.status = chromeos::UPDATE_STATUS_DOWNLOADING;
54 status.download_progress = 10;
55 CallObservers(lib, observer, status);
56
57 status.status = chromeos::UPDATE_STATUS_DOWNLOADING;
58 status.download_progress = 50;
59 CallObservers(lib, observer, status);
60
61 status.status = chromeos::UPDATE_STATUS_DOWNLOADING;
62 status.download_progress = 90;
63 CallObservers(lib, observer, status);
64
65 status.status = chromeos::UPDATE_STATUS_VERIFYING;
66 CallObservers(lib, observer, status);
67
68 status.status = chromeos::UPDATE_STATUS_FINALIZING;
69 CallObservers(lib, observer, status);
70
71 status.status = chromeos::UPDATE_STATUS_UPDATED_NEED_REBOOT;
72 CallObservers(lib, observer, status);
73 }
74
75 void FireFailureSequence(chromeos::MockUpdateLibrary* lib,
76 Observers* observer) {
77 chromeos::UpdateLibrary::Status status;
78
79 status.status = chromeos::UPDATE_STATUS_IDLE;
80 CallObservers(lib, observer, status);
81
82 status.status = chromeos::UPDATE_STATUS_CHECKING_FOR_UPDATE;
83 CallObservers(lib, observer, status);
84
85 status.status = chromeos::UPDATE_STATUS_UPDATE_AVAILABLE;
86 CallObservers(lib, observer, status);
87
88 status.status = chromeos::UPDATE_STATUS_DOWNLOADING;
89 status.download_progress = 10;
90 CallObservers(lib, observer, status);
91
92 status.status = chromeos::UPDATE_STATUS_ERROR;
93 status.download_progress = 10;
94 CallObservers(lib, observer, status);
95 }
96
97 class UpdateBrowserTest : public InProcessBrowserTest {
98 public:
99 UpdateBrowserTest() {}
100 };
101
102 IN_PROC_BROWSER_TEST_F(UpdateBrowserTest, Notifications) {
103 scoped_ptr<chromeos::MockUpdateLibrary> lib(
104 new chromeos::MockUpdateLibrary());
105
106 Observers observers;
107
108 EXPECT_CALL(*lib, AddObserver(_))
109 .WillRepeatedly(Invoke(&observers,
110 &Observers::AddObserver));
111
112 chromeos::UpdateObserver* observe =
113 new chromeos::UpdateObserver(browser()->profile());
114 lib->AddObserver(observe);
115
116 FireSuccessSequence(lib.get(), &observers);
117 FireFailureSequence(lib.get(), &observers);
118 }
119
120 } // namespace
121
OLDNEW
« 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