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

Side by Side Diff: chrome/browser/ui/cocoa/intents/web_intent_picker_view_controller_browsertest.mm

Issue 11009017: Mac Web Intents Part 11: Progress view (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: a Created 8 years, 2 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/utf_string_conversions.h" 5 #include "base/utf_string_conversions.h"
6 #include "chrome/browser/ui/browser.h" 6 #include "chrome/browser/ui/browser.h"
7 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_co ntroller.h" 7 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_co ntroller.h"
8 #import "chrome/browser/ui/cocoa/intents/web_intent_picker_cocoa2.h" 8 #import "chrome/browser/ui/cocoa/intents/web_intent_picker_cocoa2.h"
9 #import "chrome/browser/ui/cocoa/intents/web_intent_picker_view_controller.h" 9 #import "chrome/browser/ui/cocoa/intents/web_intent_picker_view_controller.h"
10 #import "chrome/browser/ui/cocoa/intents/web_intent_view_controller_message.h"
11 #import "chrome/browser/ui/cocoa/intents/web_intent_view_controller_progress.h"
10 #include "chrome/browser/ui/cocoa/run_loop_testing.h" 12 #include "chrome/browser/ui/cocoa/run_loop_testing.h"
13 #import "chrome/browser/ui/cocoa/spinner_progress_indicator.h"
11 #include "chrome/browser/ui/intents/web_intent_picker_delegate_mock.h" 14 #include "chrome/browser/ui/intents/web_intent_picker_delegate_mock.h"
12 #include "chrome/browser/ui/tab_contents/tab_contents.h" 15 #include "chrome/browser/ui/tab_contents/tab_contents.h"
13 #include "chrome/browser/ui/tabs/tab_strip_model.h" 16 #include "chrome/browser/ui/tabs/tab_strip_model.h"
14 #include "chrome/test/base/in_process_browser_test.h" 17 #include "chrome/test/base/in_process_browser_test.h"
15 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
16 #import "testing/gtest_mac.h" 19 #import "testing/gtest_mac.h"
17 20
18 namespace { 21 namespace {
19 22
20 NSString* const kTitle = @"A quick brown fox jumps over the lazy dog."; 23 NSString* const kTitle = @"A quick brown fox jumps over the lazy dog.";
(...skipping 30 matching lines...) Expand all
51 }; 54 };
52 55
53 // Test that the view is created and embedded in the constrained window. 56 // Test that the view is created and embedded in the constrained window.
54 IN_PROC_BROWSER_TEST_F(WebIntentPickerViewControllerTest, View) { 57 IN_PROC_BROWSER_TEST_F(WebIntentPickerViewControllerTest, View) {
55 EXPECT_TRUE([controller_ view]); 58 EXPECT_TRUE([controller_ view]);
56 EXPECT_TRUE([[controller_ view] superview]); 59 EXPECT_TRUE([[controller_ view] superview]);
57 EXPECT_NSEQ([picker_->window_controller() window], 60 EXPECT_NSEQ([picker_->window_controller() window],
58 [[controller_ view] window]); 61 [[controller_ view] window]);
59 } 62 }
60 63
64 // Test the "waiting for chrome web store" state.
65 IN_PROC_BROWSER_TEST_F(WebIntentPickerViewControllerTest, Waiting) {
66 model_.SetWaitingForSuggestions(true);
67 EXPECT_EQ(PICKER_STATE_WAITING, [controller_ state]);
68 WebIntentViewControllerProgress* progress_controller =
69 [controller_ progressViewController];
70 EXPECT_NSEQ([controller_ view], [[progress_controller view] superview]);
71 EXPECT_TRUE([[progress_controller progressIndicator] isIndeterminate]);
72 }
73
61 // Test the "no matching services" state. 74 // Test the "no matching services" state.
62 IN_PROC_BROWSER_TEST_F(WebIntentPickerViewControllerTest, NoServices) { 75 IN_PROC_BROWSER_TEST_F(WebIntentPickerViewControllerTest, NoServices) {
63 model_.SetWaitingForSuggestions(false); 76 model_.SetWaitingForSuggestions(false);
64 EXPECT_EQ(PICKER_STATE_NO_SERVICE, [controller_ state]); 77 EXPECT_EQ(PICKER_STATE_NO_SERVICE, [controller_ state]);
65 WebIntentViewControllerMessage* message_controller = 78 WebIntentViewControllerMessage* message_controller =
66 [controller_ messageViewController]; 79 [controller_ messageViewController];
67 EXPECT_NSEQ([controller_ view], [[message_controller view] superview]); 80 EXPECT_NSEQ([controller_ view], [[message_controller view] superview]);
68 } 81 }
82
83 // Test the "installing a service" state.
84 IN_PROC_BROWSER_TEST_F(WebIntentPickerViewControllerTest, Installing) {
85 // Add a suggested service.
86 std::vector<WebIntentPickerModel::SuggestedExtension> suggestions;
87 WebIntentPickerModel::SuggestedExtension suggestion(
88 ASCIIToUTF16("Title"), "1234", 2);
89 suggestions.push_back(suggestion);
90 model_.AddSuggestedExtensions(suggestions);
91
92 // Set a pending extension download.
93 model_.SetWaitingForSuggestions(false);
94 model_.SetPendingInstallExtensionId(suggestion.id);
95 EXPECT_EQ(PICKER_STATE_INSTALLING_EXTENSION, [controller_ state]);
96
97 WebIntentViewControllerProgress* progress_controller =
98 [controller_ progressViewController];
99 EXPECT_NSEQ([controller_ view], [[progress_controller view] superview]);
100 SpinnerProgressIndicator* progress_indicator =
101 [progress_controller progressIndicator];
102 EXPECT_FALSE([progress_indicator isIndeterminate]);
103
104 int percent_done = 50;
105 model_.SetPendingInstallDownloadPercent(percent_done);
106 EXPECT_EQ(percent_done, [progress_indicator percentDone]);
107 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698