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

Side by Side Diff: chrome/browser/devtools/device/adb/mock_adb_server.cc

Issue 291893011: DevTools: Stop asking Android devices for installed packages list (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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/devtools/device/adb/adb_device_info_query.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/strings/string_number_conversions.h" 5 #include "base/strings/string_number_conversions.h"
6 #include "base/strings/string_util.h" 6 #include "base/strings/string_util.h"
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "base/threading/non_thread_safe.h" 8 #include "base/threading/non_thread_safe.h"
9 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
10 #include "content/public/test/browser_test.h" 10 #include "content/public/test/browser_test.h"
11 #include "content/public/test/test_utils.h" 11 #include "content/public/test/test_utils.h"
12 #include "net/base/io_buffer.h" 12 #include "net/base/io_buffer.h"
13 #include "net/base/ip_endpoint.h" 13 #include "net/base/ip_endpoint.h"
14 #include "net/base/net_errors.h" 14 #include "net/base/net_errors.h"
15 #include "net/socket/stream_socket.h" 15 #include "net/socket/stream_socket.h"
16 #include "net/socket/tcp_server_socket.h" 16 #include "net/socket/tcp_server_socket.h"
17 17
18 using content::BrowserThread; 18 using content::BrowserThread;
19 19
20 namespace { 20 namespace {
21 21
22 const char kHostTransportPrefix[] = "host:transport:"; 22 const char kHostTransportPrefix[] = "host:transport:";
23 const char kLocalAbstractPrefix[] = "localabstract:"; 23 const char kLocalAbstractPrefix[] = "localabstract:";
24 24
25 const char kOpenedUnixSocketsCommand[] = "shell:cat /proc/net/unix"; 25 const char kOpenedUnixSocketsCommand[] = "shell:cat /proc/net/unix";
26 const char kDeviceModelCommand[] = "shell:getprop ro.product.model"; 26 const char kDeviceModelCommand[] = "shell:getprop ro.product.model";
27 const char kDumpsysCommand[] = "shell:dumpsys window policy"; 27 const char kDumpsysCommand[] = "shell:dumpsys window policy";
28 const char kListProcessesCommand[] = "shell:ps"; 28 const char kListProcessesCommand[] = "shell:ps";
29 const char kInstalledChromePackagesCommand[] = "shell:pm list packages";
30 29
31 const char kSerialOnline[] = "01498B321301A00A"; 30 const char kSerialOnline[] = "01498B321301A00A";
32 const char kSerialOffline[] = "01498B2B0D01300E"; 31 const char kSerialOffline[] = "01498B2B0D01300E";
33 const char kDeviceModel[] = "Nexus 6"; 32 const char kDeviceModel[] = "Nexus 6";
34 33
35 const char kJsonVersionPath[] = "/json/version"; 34 const char kJsonVersionPath[] = "/json/version";
36 const char kJsonPath[] = "/json"; 35 const char kJsonPath[] = "/json";
37 const char kJsonListPath[] = "/json/list"; 36 const char kJsonListPath[] = "/json/list";
38 37
39 const char kHttpRequestTerminator[] = "\r\n\r\n"; 38 const char kHttpRequestTerminator[] = "\r\n\r\n";
(...skipping 20 matching lines...) Expand all
60 59
61 const char kSampleListProcesses[] = 60 const char kSampleListProcesses[] =
62 "USER PID PPID VSIZE RSS WCHAN PC NAME\n" 61 "USER PID PPID VSIZE RSS WCHAN PC NAME\n"
63 "root 1 0 688 508 ffffffff 00000000 S /init\r\n" 62 "root 1 0 688 508 ffffffff 00000000 S /init\r\n"
64 "u0_a75 2425 123 933736 193024 ffffffff 00000000 S com.sample.feed\r\n" 63 "u0_a75 2425 123 933736 193024 ffffffff 00000000 S com.sample.feed\r\n"
65 "nfc 741 123 706448 26316 ffffffff 00000000 S com.android.nfc\r\n" 64 "nfc 741 123 706448 26316 ffffffff 00000000 S com.android.nfc\r\n"
66 "u0_a76 1001 124 111111 222222 ffffffff 00000000 S com.android.chrome\r\n" 65 "u0_a76 1001 124 111111 222222 ffffffff 00000000 S com.android.chrome\r\n"
67 "u0_a77 1002 125 111111 222222 ffffffff 00000000 S com.chrome.beta\r\n" 66 "u0_a77 1002 125 111111 222222 ffffffff 00000000 S com.chrome.beta\r\n"
68 "u0_a78 1003 126 111111 222222 ffffffff 00000000 S com.noprocess.app\r\n"; 67 "u0_a78 1003 126 111111 222222 ffffffff 00000000 S com.noprocess.app\r\n";
69 68
70 const char kSampleListPackages[] =
71 "package:com.sample.feed\r\n"
72 "package:com.android.nfc\r\n"
73 "package:com.android.chrome\r\n"
74 "package:com.chrome.beta\r\n"
75 "package:com.google.android.apps.chrome\r\n";
76
77 const char kSampleDumpsys[] = 69 const char kSampleDumpsys[] =
78 "WINDOW MANAGER POLICY STATE (dumpsys window policy)\r\n" 70 "WINDOW MANAGER POLICY STATE (dumpsys window policy)\r\n"
79 " mSafeMode=false mSystemReady=true mSystemBooted=true\r\n" 71 " mSafeMode=false mSystemReady=true mSystemBooted=true\r\n"
80 " mStable=(0,50)-(720,1184)\r\n" // Only mStable parameter is parsed 72 " mStable=(0,50)-(720,1184)\r\n" // Only mStable parameter is parsed
81 " mForceStatusBar=false mForceStatusBarFromKeyguard=false\r\n"; 73 " mForceStatusBar=false mForceStatusBarFromKeyguard=false\r\n";
82 74
83 char kSampleChromeVersion[] = "{\n" 75 char kSampleChromeVersion[] = "{\n"
84 " \"Browser\": \"Chrome/32.0.1679.0\",\n" 76 " \"Browser\": \"Chrome/32.0.1679.0\",\n"
85 " \"Protocol-Version\": \"1.0\",\n" 77 " \"Protocol-Version\": \"1.0\",\n"
86 " \"User-Agent\": \"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 " 78 " \"User-Agent\": \"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 "
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 } else if (selected_device_ != kSerialOnline) { 465 } else if (selected_device_ != kSerialOnline) {
474 NOTREACHED() << "Unknown device - " << selected_device_; 466 NOTREACHED() << "Unknown device - " << selected_device_;
475 } else if (command == kDeviceModelCommand) { 467 } else if (command == kDeviceModelCommand) {
476 SendResponse(kDeviceModel); 468 SendResponse(kDeviceModel);
477 } else if (command == kOpenedUnixSocketsCommand) { 469 } else if (command == kOpenedUnixSocketsCommand) {
478 SendResponse(kSampleOpenedUnixSockets); 470 SendResponse(kSampleOpenedUnixSockets);
479 } else if (command == kDumpsysCommand) { 471 } else if (command == kDumpsysCommand) {
480 SendResponse(kSampleDumpsys); 472 SendResponse(kSampleDumpsys);
481 } else if (command == kListProcessesCommand) { 473 } else if (command == kListProcessesCommand) {
482 SendResponse(kSampleListProcesses); 474 SendResponse(kSampleListProcesses);
483 } else if (command == kInstalledChromePackagesCommand) {
484 SendResponse(kSampleListPackages);
485 } else if (command.find(kLocalAbstractPrefix) == 0) { 475 } else if (command.find(kLocalAbstractPrefix) == 0) {
486 selected_socket_ = command.substr(strlen(kLocalAbstractPrefix)); 476 selected_socket_ = command.substr(strlen(kLocalAbstractPrefix));
487 SendResponse(""); 477 SendResponse("");
488 } else { 478 } else {
489 NOTREACHED() << "Unknown command - " << command; 479 NOTREACHED() << "Unknown command - " << command;
490 } 480 }
491 } 481 }
492 482
493 void SendResponse(const std::string& response) { 483 void SendResponse(const std::string& response) {
494 CHECK(CalledOnValidThread()); 484 CHECK(CalledOnValidThread());
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 538
549 void StopMockAdbServer() { 539 void StopMockAdbServer() {
550 BrowserThread::PostTaskAndReply( 540 BrowserThread::PostTaskAndReply(
551 BrowserThread::IO, 541 BrowserThread::IO,
552 FROM_HERE, 542 FROM_HERE,
553 base::Bind(&StopMockAdbServerOnIOThread), 543 base::Bind(&StopMockAdbServerOnIOThread),
554 base::MessageLoop::QuitClosure()); 544 base::MessageLoop::QuitClosure());
555 content::RunMessageLoop(); 545 content::RunMessageLoop();
556 } 546 }
557 547
OLDNEW
« no previous file with comments | « chrome/browser/devtools/device/adb/adb_device_info_query.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698