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

Side by Side Diff: google_apis/google_api_keys_unittest.cc

Issue 2786033002: Expose way to set google api key through CWVWebView class method. (Closed)
Patch Set: last patch Created 3 years, 8 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 | « google_apis/google_api_keys.cc ('k') | ios/web_view/internal/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Unit tests for implementation of google_api_keys namespace. 5 // Unit tests for implementation of google_api_keys namespace.
6 // 6 //
7 // Because the file deals with a lot of preprocessor defines and 7 // Because the file deals with a lot of preprocessor defines and
8 // optionally includes an internal header, the way we test is by 8 // optionally includes an internal header, the way we test is by
9 // including the .cc file multiple times with different defines set. 9 // including the .cc file multiple times with different defines set.
10 // This is a little unorthodox, but it lets us test the behavior as 10 // This is a little unorthodox, but it lets us test the behavior as
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 EXPECT_EQ("env-ID_MAIN", id_main); 474 EXPECT_EQ("env-ID_MAIN", id_main);
475 EXPECT_EQ("env-SECRET_MAIN", secret_main); 475 EXPECT_EQ("env-SECRET_MAIN", secret_main);
476 EXPECT_EQ("env-ID_CLOUD_PRINT", id_cloud_print); 476 EXPECT_EQ("env-ID_CLOUD_PRINT", id_cloud_print);
477 EXPECT_EQ("env-SECRET_CLOUD_PRINT", secret_cloud_print); 477 EXPECT_EQ("env-SECRET_CLOUD_PRINT", secret_cloud_print);
478 EXPECT_EQ("env-ID_REMOTING", id_remoting); 478 EXPECT_EQ("env-ID_REMOTING", id_remoting);
479 EXPECT_EQ("env-SECRET_REMOTING", secret_remoting); 479 EXPECT_EQ("env-SECRET_REMOTING", secret_remoting);
480 EXPECT_EQ("env-ID_REMOTING_HOST", id_remoting_host); 480 EXPECT_EQ("env-ID_REMOTING_HOST", id_remoting_host);
481 EXPECT_EQ("env-SECRET_REMOTING_HOST", secret_remoting_host); 481 EXPECT_EQ("env-SECRET_REMOTING_HOST", secret_remoting_host);
482 } 482 }
483 483
484 TEST_F(GoogleAPIKeysTest, OverrideAllKeysUsingSetters) {
Eugene But (OOO till 7-30) 2017/04/19 16:27:14 Could you please add a comment explaining what thi
jzw1 2017/04/20 07:59:49 Done.
485 namespace testcase = google_apis;
486
487 std::string api_key("setter-API_KEY");
Eugene But (OOO till 7-30) 2017/04/19 16:27:14 Would it be better to split this test into multipl
jzw1 2017/04/20 07:59:49 I feel like this test is set up in a very similar
488 testcase::SetAPIKey(api_key);
489
490 std::string id_main("setter-ID_MAIN");
491 std::string secret_main("setter-SECRET_MAIN");
492 testcase::SetOAuth2ClientID(testcase::CLIENT_MAIN, id_main);
493 testcase::SetOAuth2ClientSecret(testcase::CLIENT_MAIN, secret_main);
494
495 std::string id_cloud_print("setter-ID_CLOUD_PRINT");
496 std::string secret_cloud_print("setter-SECRET_CLOUD_PRINT");
497 testcase::SetOAuth2ClientID(testcase::CLIENT_CLOUD_PRINT, id_cloud_print);
498 testcase::SetOAuth2ClientSecret(testcase::CLIENT_CLOUD_PRINT,
499 secret_cloud_print);
500
501 std::string id_remoting("setter-ID_REMOTING");
502 std::string secret_remoting("setter-SECRET_REMOTING");
503 testcase::SetOAuth2ClientID(testcase::CLIENT_REMOTING, id_remoting);
504 testcase::SetOAuth2ClientSecret(testcase::CLIENT_REMOTING, secret_remoting);
505
506 std::string id_remoting_host("setter-ID_REMOTING_HOST");
507 std::string secret_remoting_host("setter-SECRET_REMOTING_HOST");
508 testcase::SetOAuth2ClientID(testcase::CLIENT_REMOTING_HOST, id_remoting_host);
509 testcase::SetOAuth2ClientSecret(testcase::CLIENT_REMOTING_HOST,
510 secret_remoting_host);
511
512 EXPECT_TRUE(testcase::HasKeysConfigured());
513
514 EXPECT_EQ(api_key, testcase::GetAPIKey());
515
516 EXPECT_EQ(id_main, testcase::GetOAuth2ClientID(testcase::CLIENT_MAIN));
517 EXPECT_EQ(secret_main,
518 testcase::GetOAuth2ClientSecret(testcase::CLIENT_MAIN));
519
520 EXPECT_EQ(id_cloud_print,
521 testcase::GetOAuth2ClientID(testcase::CLIENT_CLOUD_PRINT));
522 EXPECT_EQ(secret_cloud_print,
523 testcase::GetOAuth2ClientSecret(testcase::CLIENT_CLOUD_PRINT));
524
525 EXPECT_EQ(id_remoting,
526 testcase::GetOAuth2ClientID(testcase::CLIENT_REMOTING));
527 EXPECT_EQ(secret_remoting,
528 testcase::GetOAuth2ClientSecret(testcase::CLIENT_REMOTING));
529
530 EXPECT_EQ(id_remoting_host,
531 testcase::GetOAuth2ClientID(testcase::CLIENT_REMOTING_HOST));
532 EXPECT_EQ(secret_remoting_host,
533 testcase::GetOAuth2ClientSecret(testcase::CLIENT_REMOTING_HOST));
534 }
Roger Tawa OOO till Jul 10th 2017/04/19 18:32:20 Doesn't this test need to be inside an #ifdef for
jzw1 2017/04/20 07:59:49 Oh dear god yes. Thanks for catching that.
535
484 #endif // defined(OS_LINUX) || defined(OS_MACOSX) 536 #endif // defined(OS_LINUX) || defined(OS_MACOSX)
OLDNEW
« no previous file with comments | « google_apis/google_api_keys.cc ('k') | ios/web_view/internal/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698