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

Side by Side Diff: chrome/browser/ui/cocoa/chrome_to_mobile_bubble_controller_unittest.mm

Issue 10808068: Store ChromeToMobile device list and timestamp prefs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add GetMobiles ownership/lifetime comment. Created 8 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 | Annotate | Revision Log
OLDNEW
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 "base/values.h" 5 #include "base/values.h"
6 #include "chrome/browser/chrome_to_mobile_service.h" 6 #include "chrome/browser/chrome_to_mobile_service.h"
7 #import "chrome/browser/ui/cocoa/chrome_to_mobile_bubble_controller.h" 7 #import "chrome/browser/ui/cocoa/chrome_to_mobile_bubble_controller.h"
8 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" 8 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
9 #include "testing/gmock/include/gmock/gmock.h" 9 #include "testing/gmock/include/gmock/gmock.h"
10 10
11 // Caution!!! Do not conflict with this class name elsewhere! 11 // Caution!!! Do not conflict with this class name elsewhere!
12 class MockChromeToMobileService : public ChromeToMobileService { 12 class MockChromeToMobileService : public ChromeToMobileService {
13 public: 13 public:
14 MockChromeToMobileService() : ChromeToMobileService(NULL) {} 14 MockChromeToMobileService() : ChromeToMobileService(NULL) {}
15 15
16 // A utility function to add mock devices. 16 // A utility function to add mock devices.
17 void AddDevices(size_t count); 17 void AddDevices(size_t count);
18 18
19 // ChromeToMobileService overrides:
20 virtual const base::ListValue* GetMobiles() const OVERRIDE;
21
19 MOCK_METHOD0(RequestMobileListUpdate, void()); 22 MOCK_METHOD0(RequestMobileListUpdate, void());
20 MOCK_METHOD2(GenerateSnapshot, void(Browser* browser, 23 MOCK_METHOD2(GenerateSnapshot, void(Browser* browser,
21 base::WeakPtr<Observer> observer)); 24 base::WeakPtr<Observer> observer));
22 MOCK_METHOD4(SendToMobile, void(const base::DictionaryValue& mobile, 25 MOCK_METHOD4(SendToMobile, void(const base::DictionaryValue& mobile,
23 const FilePath& snapshot, 26 const FilePath& snapshot,
24 Browser* browser, 27 Browser* browser,
25 base::WeakPtr<Observer> observer)); 28 base::WeakPtr<Observer> observer));
26 MOCK_METHOD1(DeleteSnapshot, void(const FilePath& snapshot)); 29 MOCK_METHOD1(DeleteSnapshot, void(const FilePath& snapshot));
27 MOCK_CONST_METHOD1(LogMetric, void(ChromeToMobileService::Metric)); 30 MOCK_CONST_METHOD1(LogMetric, void(ChromeToMobileService::Metric));
31
32 // A set of mock mobile devices, kept in lieu of the list in profile prefs.
33 base::ListValue mobiles_;
28 }; 34 };
29 35
30 void MockChromeToMobileService::AddDevices(size_t count) { 36 void MockChromeToMobileService::AddDevices(size_t count) {
31 for(size_t i = 0; i < count; i++) { 37 for(size_t i = 0; i < count; i++) {
32 base::DictionaryValue* device = new base::DictionaryValue(); 38 base::DictionaryValue* device = new base::DictionaryValue();
33 device->SetString("name", "Device Name"); 39 device->SetString("name", "Device Name");
34 mobiles_.Append(device); 40 mobiles_.Append(device);
35 } 41 }
36 } 42 }
37 43
44 const base::ListValue* MockChromeToMobileService::GetMobiles() const {
45 return &mobiles_;
46 }
47
38 namespace { 48 namespace {
39 49
40 class ChromeToMobileBubbleControllerTest : public CocoaTest { 50 class ChromeToMobileBubbleControllerTest : public CocoaTest {
41 public: 51 public:
42 ChromeToMobileBubbleControllerTest() : controller_(NULL) {} 52 ChromeToMobileBubbleControllerTest() : controller_(NULL) {}
43 virtual ~ChromeToMobileBubbleControllerTest() {} 53 virtual ~ChromeToMobileBubbleControllerTest() {}
44 54
45 virtual void TearDown() { 55 virtual void TearDown() {
46 [controller_ close]; 56 [controller_ close];
47 CocoaTest::TearDown(); 57 CocoaTest::TearDown();
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 CreateBubble(); 173 CreateBubble();
164 ChromeToMobileBubbleNotificationBridge* bridge = [controller_ bridge]; 174 ChromeToMobileBubbleNotificationBridge* bridge = [controller_ bridge];
165 bridge->SnapshotGenerated(path, 1); 175 bridge->SnapshotGenerated(path, 1);
166 [controller_ setSendCopy:YES]; 176 [controller_ setSendCopy:YES];
167 [controller_ send:nil]; 177 [controller_ send:nil];
168 // Send failure to prevent the bubble from posting a task to close itself. 178 // Send failure to prevent the bubble from posting a task to close itself.
169 bridge->OnSendComplete(false); 179 bridge->OnSendComplete(false);
170 } 180 }
171 181
172 } // namespace 182 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698