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

Side by Side Diff: chrome/browser/ui/views/translate/translate_bubble_view_unittest.cc

Issue 2088053002: Split to use two different ID for the two different checkbox in two different subview. Currently th… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 6 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
« no previous file with comments | « chrome/browser/ui/views/translate/translate_bubble_view.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/browser/ui/views/translate/translate_bubble_view.h" 5 #include "chrome/browser/ui/views/translate/translate_bubble_view.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 TEST_F(TranslateBubbleViewTest, AlwaysTranslateCheckboxAndCancelButton) { 343 TEST_F(TranslateBubbleViewTest, AlwaysTranslateCheckboxAndCancelButton) {
344 CreateAndShowBubble(); 344 CreateAndShowBubble();
345 bubble_->SwitchView(TranslateBubbleModel::VIEW_STATE_ADVANCED); 345 bubble_->SwitchView(TranslateBubbleModel::VIEW_STATE_ADVANCED);
346 346
347 // Click the "Always Translate" checkbox. Changing the state of this checkbox 347 // Click the "Always Translate" checkbox. Changing the state of this checkbox
348 // should NOT affect the model after pressing the cancel button. 348 // should NOT affect the model after pressing the cancel button.
349 349
350 // Check the initial state. 350 // Check the initial state.
351 EXPECT_FALSE(mock_model_->should_always_translate_); 351 EXPECT_FALSE(mock_model_->should_always_translate_);
352 EXPECT_EQ(0, mock_model_->set_always_translate_called_count_); 352 EXPECT_EQ(0, mock_model_->set_always_translate_called_count_);
353 EXPECT_FALSE(bubble_->always_translate_checkbox_->checked()); 353 EXPECT_FALSE(bubble_->advanced_always_translate_checkbox_->checked());
354 354
355 // Click the checkbox. The state is not saved yet. 355 // Click the checkbox. The state is not saved yet.
356 bubble_->always_translate_checkbox_->SetChecked(true); 356 bubble_->advanced_always_translate_checkbox_->SetChecked(true);
357 bubble_->HandleButtonPressed(TranslateBubbleView::BUTTON_ID_ALWAYS_TRANSLATE); 357 bubble_->HandleButtonPressed(TranslateBubbleView::BUTTON_ID_ALWAYS_TRANSLATE);
358 EXPECT_FALSE(mock_model_->should_always_translate_); 358 EXPECT_FALSE(mock_model_->should_always_translate_);
359 EXPECT_EQ(0, mock_model_->set_always_translate_called_count_); 359 EXPECT_EQ(0, mock_model_->set_always_translate_called_count_);
360 360
361 // Click the cancel button. The state is not saved. 361 // Click the cancel button. The state is not saved.
362 bubble_->HandleButtonPressed(TranslateBubbleView::BUTTON_ID_CANCEL); 362 bubble_->HandleButtonPressed(TranslateBubbleView::BUTTON_ID_CANCEL);
363 EXPECT_FALSE(mock_model_->should_always_translate_); 363 EXPECT_FALSE(mock_model_->should_always_translate_);
364 EXPECT_EQ(0, mock_model_->set_always_translate_called_count_); 364 EXPECT_EQ(0, mock_model_->set_always_translate_called_count_);
365 } 365 }
366 366
367 TEST_F(TranslateBubbleViewTest, AlwaysTranslateCheckboxAndDoneButton) { 367 TEST_F(TranslateBubbleViewTest, AlwaysTranslateCheckboxAndDoneButton) {
368 CreateAndShowBubble(); 368 CreateAndShowBubble();
369 bubble_->SwitchView(TranslateBubbleModel::VIEW_STATE_ADVANCED); 369 bubble_->SwitchView(TranslateBubbleModel::VIEW_STATE_ADVANCED);
370 370
371 // Click the "Always Translate" checkbox. Changing the state of this checkbox 371 // Click the "Always Translate" checkbox. Changing the state of this checkbox
372 // should affect the model after pressing the done button. 372 // should affect the model after pressing the done button.
373 373
374 // Check the initial state. 374 // Check the initial state.
375 EXPECT_FALSE(mock_model_->should_always_translate_); 375 EXPECT_FALSE(mock_model_->should_always_translate_);
376 EXPECT_EQ(0, mock_model_->set_always_translate_called_count_); 376 EXPECT_EQ(0, mock_model_->set_always_translate_called_count_);
377 EXPECT_FALSE(bubble_->always_translate_checkbox_->checked()); 377 EXPECT_FALSE(bubble_->advanced_always_translate_checkbox_->checked());
378 378
379 // Click the checkbox. The state is not saved yet. 379 // Click the checkbox. The state is not saved yet.
380 bubble_->always_translate_checkbox_->SetChecked(true); 380 bubble_->advanced_always_translate_checkbox_->SetChecked(true);
381 bubble_->HandleButtonPressed(TranslateBubbleView::BUTTON_ID_ALWAYS_TRANSLATE); 381 bubble_->HandleButtonPressed(TranslateBubbleView::BUTTON_ID_ALWAYS_TRANSLATE);
382 EXPECT_FALSE(mock_model_->should_always_translate_); 382 EXPECT_FALSE(mock_model_->should_always_translate_);
383 EXPECT_EQ(0, mock_model_->set_always_translate_called_count_); 383 EXPECT_EQ(0, mock_model_->set_always_translate_called_count_);
384 384
385 // Click the done button. The state is saved. 385 // Click the done button. The state is saved.
386 bubble_->HandleButtonPressed(TranslateBubbleView::BUTTON_ID_DONE); 386 bubble_->HandleButtonPressed(TranslateBubbleView::BUTTON_ID_DONE);
387 EXPECT_TRUE(mock_model_->should_always_translate_); 387 EXPECT_TRUE(mock_model_->should_always_translate_);
388 EXPECT_EQ(1, mock_model_->set_always_translate_called_count_); 388 EXPECT_EQ(1, mock_model_->set_always_translate_called_count_);
389 } 389 }
390 390
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 TEST_F(TranslateBubbleViewTest, CancelButtonReturningError) { 462 TEST_F(TranslateBubbleViewTest, CancelButtonReturningError) {
463 CreateAndShowBubble(); 463 CreateAndShowBubble();
464 bubble_->SwitchView(TranslateBubbleModel::VIEW_STATE_ERROR); 464 bubble_->SwitchView(TranslateBubbleModel::VIEW_STATE_ERROR);
465 bubble_->SwitchView(TranslateBubbleModel::VIEW_STATE_ADVANCED); 465 bubble_->SwitchView(TranslateBubbleModel::VIEW_STATE_ADVANCED);
466 466
467 // Click the "Cancel" button to go back. 467 // Click the "Cancel" button to go back.
468 EXPECT_EQ(TranslateBubbleModel::VIEW_STATE_ADVANCED, bubble_->GetViewState()); 468 EXPECT_EQ(TranslateBubbleModel::VIEW_STATE_ADVANCED, bubble_->GetViewState());
469 bubble_->HandleButtonPressed(TranslateBubbleView::BUTTON_ID_CANCEL); 469 bubble_->HandleButtonPressed(TranslateBubbleView::BUTTON_ID_CANCEL);
470 EXPECT_EQ(TranslateBubbleModel::VIEW_STATE_ERROR, bubble_->GetViewState()); 470 EXPECT_EQ(TranslateBubbleModel::VIEW_STATE_ERROR, bubble_->GetViewState());
471 } 471 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/translate/translate_bubble_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698